Skip to content

Instantly share code, notes, and snippets.

@bealdav
Created March 16, 2014 15:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bealdav/9584718 to your computer and use it in GitHub Desktop.
Save bealdav/9584718 to your computer and use it in GitHub Desktop.
This script allows to convert .bash_aliases file in config.fish used by fish shell command line see http://fishshell.com/
#!/usr/bin python
# -*- coding: utf-8 -*-
"""
This script allows to convert .bash_aliases file
in config.fish used by fish shell command line
see http://fishshell.com/
"""
# change your path
alias ='../../.bash_aliases'
fish = '../../.config/fish/config.fish'
collect = []
def format_fish(component):
short, cmd = component
return """
function %s
%s $argv
end
""" % (component[0], component[1])
with open(alias, 'r') as alias_file:
for line in alias_file:
if line[:6] == 'alias ':
component = line[6:].replace('"\n', '').split('="')
if len(component) == 2:
collect.append(format_fish(component))
if collect:
with open(fish, 'w') as fi:
fi.write(''.join(collect))
print " >>>> 'config.fish' file updated"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment