Created
June 11, 2016 10:35
-
-
Save HiR0GeN/fcacc28b1310bc8aaac68977dc03bf7c to your computer and use it in GitHub Desktop.
Fish function to import bash aliases to fish functions
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
# Fish function to import bash aliases v0.2 | |
# Copyright (C) 2016 Malte Biermann | |
# Released under the GPL | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
function import_bash_aliases --description 'bash aliases to .fish function files ' | |
for a in (cat ~/.bashrc | grep "^alias") | |
#echo $a | |
set aname (echo $a | sed 's/alias \(.*\)=".*/\1/') | |
#echo $aname | |
set command (echo $a | sed 's/alias.*="\(.*\)"/\1/') | |
#echo $command | |
echo "Processing alias $aname as $command" | |
if test -f ~/.config/fish/functions/$aname.fish | |
echo Function $aname is already defined. Skipping ... | |
else | |
alias $aname $command | |
funcsave $aname | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist only works for aliases with the following format:
alias name="command"