Skip to content

Instantly share code, notes, and snippets.

@ngty
Created April 7, 2009 10:01
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngty/91167 to your computer and use it in GitHub Desktop.
Save ngty/91167 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
`cat ~/.bash_aliases | egrep '^alias' | sed 's/alias//'`.split("\n").each do |line|
parts = line.strip.split(/=/)
name, cmd = parts[0], parts[1].gsub(/('|")/,'')
file = '/home/%s/.config/fish/functions/%s.fish' % [`whoami`.strip, name]
content = [ 'function %s' % name, ' %s $argv;' % cmd, 'end' ].join("\n")
File.open(file, 'w+'){|io| io.write(content) }
end
@airbugg
Copy link

airbugg commented Sep 4, 2018

This was exactly what I was looking for, and it worked flawlessly (after modifying the relevant paths, of course.)

Thank you so much!

@ipstone
Copy link

ipstone commented Nov 5, 2018

why not juse copying .bash_aliases and then convert '&&' to '; and' ('||' to ; or)? It works for mosf of my bash_aliases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment