Posted By

deepsoul on 08/02/09


Tagged

cd mkdir rmdir


Versions (?)

Combined make/remove and change directory


 / Published in: Bash
 

Has saved me no end of typing over the years.

  1. # mkdir and cd into new Dir (accepts -p option of mkdir or creation of multiple dirs):
  2. function mkcd() { mkdir "$@" && cd "${!#}"; }
  3.  
  4. # usage:
  5. mkcd newdir
  6. # or:
  7. mkcd -p path/to/newdir
  8.  
  9. # cd .. and remove directory:
  10. function rmcd() { cd .. && rmdir "${OLDPWD##*/}"; }
  11.  
  12. # usage, from empty directory you want to remove:
  13. rmcd

Report this snippet  

You need to login to post a comment.