Last active
October 11, 2019 09:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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