例如,我想以详细格式ls -l
而不是通常的ls
格式列出当前工作目录中的所有文件,而不必每次都输入该选项。任何帮助,将不胜感激。谢谢。
答案 0 :(得分:1)
你称之为“宏”,在bash中被定义为“别名”。从man bash
(在第3744行的某处):
alias [-p] [name[=value] ...] Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output. When arguments are supplied, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded. For each name in the argument list for which no value is sup‐ plied, the name and value of the alias is printed. Alias returns true unless a name is given for which no alias has been defined.
您可以在~/.bash_aliases
文件中创建别名,如下所示:
alias ls="ls -l"
此外,在Ubuntu 12.04中,ls
文件中已存在~/.bashrc
的别名,您可以根据需要进行更新。要找到它,请搜索以下行:
alias ls="ls --color=auto"
并将其更改为:
alias ls="ls --color=auto -l"
的更多信息