linux中执行cd之后直接ls列出所有文件

以下command在cshell中生效

在.cshrc中加入下面的语句:

alias cd 'cd \!* ; ll'

注意*后面的空格,以及ll之前的空格

进一步,可以同时打印出cd之后的path

alias cd 'cd \!* ; ll; pwd'

如果执行cd之后命令行显示的目录(用户名后面紧跟着的)没有变化的,可以试着再加入source

alias cd 'cd \!* ; ll; pwd; so'

 

如果是在bash的环境,在.bashrc中加入:

alias cd="cd $1; ll "

Note the leading space (" ") in the bash version, it prevents the result to be alias expanded again. So it prevents loops.

bash另一种方法,在.bashrc中加入:

  1. cdls() {  
  2.     cd "${1}";  
  3.     ls;  
  4. }  
  5. alias cd='cdls'  
posted @ 2017-06-27 11:20  鱼游时光  阅读(3522)  评论(0编辑  收藏  举报