Skip to content

Instantly share code, notes, and snippets.

@rodrigobdz
Last active November 3, 2023 20:32
Show Gist options
  • Save rodrigobdz/e80accf162872914e728d90e27a1452c to your computer and use it in GitHub Desktop.
Save rodrigobdz/e80accf162872914e728d90e27a1452c to your computer and use it in GitHub Desktop.
Export fish abbreviations
#!/usr/local/bin/fish
# Use current date as name of file where fish
# abbreviations will be stored
# Format: YYYY-MM-DD
set -lx EXPORT_FILENAME (date "+%Y-%m-%d")
# Prepare destination fish script
echo "#!/usr/local/bin/fish" > $EXPORT_FILENAME.fish
# Write all abbreviations to file
abbr --show >> $EXPORT_FILENAME.fish
# Add missing "--add" parameter to each abbreviation
sed -i '' 's/abbr/& --add/g' $EXPORT_FILENAME.fish
# Make script containing abbreviations executable
chmod +x $EXPORT_FILENAME.fish
@rodrigobdz
Copy link
Author

rodrigobdz commented Jan 20, 2018

Export abbreviations as fish script

By executing the resulting fish script, all abbreviations are added to the fish environment where the script is executed∫.

Requirements

  • Fish shell

Usage

# Make script executable
$ chmod +x export_fish_abbreviations.fish
# Run script
$ ./export_fish_abbreviations.fish

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