5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

見やすいpwd

Last updated at Posted at 2018-10-20

pwdが見にくいのでaliasで使う用。zshとbashでは動くことは確認した。

echo && c=`pwd` && ds=() && d=" " && while [ "$c" != "/" ]; do ds=(`basename $c` ${ds[@]}) && c=`dirname $c`; done && if [ ${#ds[@]} -eq 0 ]; then echo ${d}"/"; else for dir in ${ds[@]}; do echo "${d}"/${dir} && d="${d} "; done; fi && echo

こうなる

% for i in {1..30}; do mkdir $i && cd $i; done # 30階層作って最下層に移動する
% pwd # 普通のpwd
/Users/ito_masakuni/Desktop/works/tmp/test/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30
% alias p='echo && c=`pwd` && ds=() && d=" " && while [ "$c" != "/" ]; do ds=(`basename $c` ${ds[@]}) && c=`dirname $c`; done && if [ ${#ds[@]} -eq 0 ]; then echo ${d}"/"; else for dir in ${ds[@]}; do echo "${d}"/${dir} && d="${d} "; done; fi && echo'
% p

 /Users
  /ito_masakuni
   /Desktop
    /works
     /tmp
      /test
       /1
        /2
         /3
          /4
           /5
            /6
             /7
              /8
               /9
                /10
                 /11
                  /12
                   /13
                    /14
                     /15
                      /16
                       /17
                        /18
                         /19
                          /20
                           /21
                            /22
                             /23
                              /24
                               /25
                                /26
                                 /27
                                  /28
                                   /29
                                    /30
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?