Creating an alias for `ls` that includes` echo` in csh

I want to create an alias that will add a space before and after each use ls. If I use only ls, the result is close to the line above, and under it it is sometimes difficult and difficult for me to read the result. So I started using the line:

echo "\n"; ls something ; echo "\n"

Is there a way to put it in an alias, so that every time I use a command ls, it will automatically add commands echo?

+3
source share
3 answers

I don't have csh / tcsh, so I can’t check, but this should work

alias ls 'echo "\n"; ls \!* ; echo "\n"'

Command line options in tcsh / csh:

  • !! is the whole command line
  • !* - all team arguments
  • !:1 is the first argument to the command
  • !:2 - second argument of the command
  • !$ -
+6
alias ls 'echo ; /bin/ls something; echo'

, ls, .

+4

This may not be wise for the alias lsdirectly, since you can use it in a script that expects normal output. Instead, an alias lssin .cshrc:

alias lss 'echo; /bin/ls; echo;'

You do not need "\n"it because it only echoprints a new line.

+4
source

All Articles