Skip to content

Instantly share code, notes, and snippets.

@okurka12
Created July 24, 2024 10:58
Show Gist options
  • Save okurka12/527bcad0ce2c6590f2524ae333d0b801 to your computer and use it in GitHub Desktop.
Save okurka12/527bcad0ce2c6590f2524ae333d0b801 to your computer and use it in GitHub Desktop.
imports aliases from .bash_aliases to config.fish as abbreviations
#!/bin/bash
#
# imports aliases from .bash_aliases to config.fish as abbreviations
#
FISHCFG=~/.config/fish/config.fish
BASH_ALIASES=~/.bash_aliases
echo "" >> $FISHCFG
echo "# bash aliases imported by $0" >> $FISHCFG
# iterate over lines having the alias keyword
grep -E "^[^#]*alias\s" "$BASH_ALIASES" | while read LINE; do
NAME=$(echo "$LINE" | cut -d' ' -f2-999 | cut -d'=' -f1)
VALUE=$(echo "$LINE" | cut -d' ' -f2-999 | cut -d'=' -f2-999)
# skip those because fish has them built in
if [ $NAME = "grep" -o $NAME = "ll" ]; then continue; fi
echo "$NAME is $VALUE"
echo "abbr --add $NAME $VALUE" >> $FISHCFG
done
echo "# end of bash aliases imported by $0" >> $FISHCFG
echo "" >> $FISHCFG
echo all aliases added to $FISHCFG as abbreviations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment