Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Last active October 11, 2019 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttscoff/2c77e4995738c535598169a186495238 to your computer and use it in GitHub Desktop.
Save ttscoff/2c77e4995738c535598169a186495238 to your computer and use it in GitHub Desktop.
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