如何在 Linux 中为“ls”设置默认参数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9120406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I set default arguments for "ls" in Linux?
提问by JoshL
Im constantly doing "ls -ahl" whenever I want to list what is in the directory. Is there a way for me to make -ahl the default args passed when I do "ls" or should I just create an alias like "alias lsa=ls -ahl" in bash_profile?
每当我想列出目录中的内容时,我都会不断地执行“ls -ahl”。有没有办法让 -ahl 成为我执行“ls”时传递的默认参数,还是应该在 bash_profile 中创建一个像“alias lsa=ls -ahl”这样的别名?
采纳答案by dlannoye
You could just alias ls itself. So something like:
你可以只是别名 ls 本身。所以像:
alias ls='ls -ahl'
回答by Kevin
Create an alias in your .bashrc
. You can even call it ls
and override the program.
在您的.bashrc
. 您甚至可以调用它ls
并覆盖该程序。
回答by Chris Seymour
Set an alias
in your ~/.bash_profile
file.
alias
在您的~/.bash_profile
文件中设置一个。
alias ls="ls -ahl"
A couple of common aliases that I use all the time are:
我一直使用的几个常见别名是:
alias ll="ls -lh --color"
alias l="ls -1"