I want to make an alias that will add a space before and after each time I use ls
. If I use just ls
the result is to close to the line above and under it it I sometimes find it hard and confusing to read the output. So I've started to use the line:
echo "\n"; ls something ; echo "\n"
Is there a way to put it in an alias, so that each time I'll use the ls
command it'll automatically add the echo
commands?
Don't have csh/tcsh available so I cannot test, but this should work
alias ls 'echo "\n"; ls \!* ; echo "\n"'
Command line parameters in tcsh/csh:
!!
is the whole command line !*
is all the arguments of the command !:1
is the first argument of the command !:2
is the second argument of the command !$
is the last argument of the command alias ls 'echo ; /bin/ls something; echo'
请注意,您必须提供ls的完整路径,否则shell会将其视为尝试再次调用别名并抱怨递归尝试。
It might be unwise to alias ls
directly, since you might use it in a script which expects the normal output. Instead, alias something like lss
in you .cshrc
:
alias lss 'echo; /bin/ls; echo;'
You don't need the "\\n"
because echo
alone simple prints a newline.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.