Skip to content

Instantly share code, notes, and snippets.

@ttscoff ttscoff/linkmarks.rb
Last active Oct 11, 2019

Embed
What would you like to do?
A script to convert Bashmarks .sdirs file to Fish's Jump plugin symlinks
#!/usr/bin/env ruby
# A script to convert Bashmarks .sdirs file to Fish's Jump plugin symlinks
sdirs_file = File.expand_path('~/.sdirs')
unless File.exists?(sdirs_file)
$stderr.puts 'Bookmarks file not found (~/.sdirs). Is Bashmarks initialized?'
Process.exit 1
end
marks = File.expand_path('~/.marks')
unless File.directory?(marks)
$stderr.puts 'It appears the Fish "jump" plugin hasn\'t been initialized.'
Process.exit 1
end
IO.read(sdirs_file).split(/\n/).each {|line|
m = line.match(/export DIR_(\S+?)="(.*?)"/)
mark_target = File.join(marks,m[1])
mark_path = m[2].sub(/^\$HOME\//,'~/')
unless File.exists?(mark_target)
cmd = %Q{ln -s "#{mark_path}" #{mark_target}}
system cmd
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.