LinuxCommandLibrary

abbr

Define and expand command abbreviations

TLDR

Add a new abbreviation

$ abbr [[-a|--add]] [abbreviation_name] [command] [command_arguments]
copy

Rename an existing abbreviation
$ abbr --rename [old_name] [new_name]
copy

Erase an existing abbreviation
$ abbr [[-e|--erase]] [abbreviation_name]
copy

Import the abbreviations defined on another host over SSH
$ ssh [host_name] abbr [[-s|--show]] | source
copy

SYNOPSIS

abbr [-a|-g|-d|-e|-l|-s|-k] [KEY [EXPANSION]]

PARAMETERS

-a, --add
    Add abbreviation (default mode)

-g, --global
    Save abbreviation persistently

-d, --delete
    Delete matching abbreviation(s)

-e, --erase
    Delete all abbreviations

-l, --list
    List all abbreviations

-s, --search
    Search abbreviations by KEY

-k, --query
    Exit 0 if KEY exists, else 1

DESCRIPTION

The abbr command is a built-in in the fish shell, used to create, manage, and remove abbreviations. Abbreviations are shortcuts that expand to full commands or text when pressing Tab, improving typing efficiency without altering the command line like aliases do.

Without arguments, abbr KEY EXPANSION adds a session-only abbreviation. Options allow listing, searching, deleting, or making them global (persistent via config.fish).

Expansions support placeholders like \u1 for first argument. Ideal for frequent commands, e.g., gcgit commit -m. Global mode (-g) saves to ~/.config/fish/config.fish for reuse.

Unlike bash aliases, fish abbreviations expand inline, enabling easy editing post-expansion. Available only in fish shell environments.

CAVEATS

Fish shell only; not in bash/zsh. Global requires config write access. Expansions use fish syntax (e.g., \u1 for arg1).

EXAMPLES

abbr gco 'git checkout'
abbr -g ll 'ls -l'
abbr -d gco
abbr -l | grep git

PLACEHOLDERS

Use \u1 (1st arg), \u2 (2nd), \u* (all args), \\ (literal backslash).

HISTORY

Introduced in fish 2.6.0 (2016) for abbreviation management. Global support added early; options refined in 3.x for scripting.

SEE ALSO

fish(1)

Copied to clipboard