Making an alias for `ls` that includes `echo` in csh
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开发者_StackOverflow 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'
Note that you have to provide the full path for ls, otherwise the shell sees it as an attempt to call the alias again and complains about the recursion attempt.
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.
精彩评论