← 返回命令列表

Linux command

abbr 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Add

abbr --add [abbreviation_name] [command] [arguments]

Rename

abbr --rename [old_name] [new_name]

Erase

abbr --erase [abbreviation_name]

List

abbr --list

Show

abbr --show

Example

ssh [hostname] abbr --show | source

说明

abbr manages abbreviations for the fish shell. Abbreviations are user-defined words that expand into longer phrases when entered at the command line and confirmed with space or enter. Unlike aliases, which are simple command substitutions, abbreviations allow the user to see and edit the expanded text before execution. Abbreviations only apply to interactively typed commands and are not expanded in scripts or functions. They can be scoped to trigger only at command position or anywhere on the line, and support regex patterns and dynamic expansions through shell functions.

参数

--add NAME EXPANSION
Create a new abbreviation that expands NAME to EXPANSION
--erase NAME
Remove one or more abbreviations
--rename OLD_WORD NEW_WORD
Rename an existing abbreviation
--show
Display all abbreviations in a format suitable for export
--list
Print only the abbreviation names
--query NAME
Check if NAME is a defined abbreviation
--position command|anywhere
Where the abbreviation expands; default is command position only
--regex PATTERN
Match using PCRE2 regular expression pattern instead of literal text
--set-cursor=MARKER
Position cursor at marker location after expansion; default marker is %
--function FUNCTION
Use function output for dynamic expansion instead of static text
--command COMMAND
Expand only when used as argument to the specified command

FAQ

What is the abbr command used for?

abbr manages abbreviations for the fish shell. Abbreviations are user-defined words that expand into longer phrases when entered at the command line and confirmed with space or enter. Unlike aliases, which are simple command substitutions, abbreviations allow the user to see and edit the expanded text before execution. Abbreviations only apply to interactively typed commands and are not expanded in scripts or functions. They can be scoped to trigger only at command position or anywhere on the line, and support regex patterns and dynamic expansions through shell functions.

How do I run a basic abbr example?

Run `abbr --add [abbreviation_name] [command] [arguments]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --add NAME EXPANSION do in abbr?

Create a new abbreviation that expands NAME to EXPANSION