HN2new | past | comments | ask | show | jobs | submitlogin

I vote for creating a « mkcd » alias !!


Here's my answer to that, an 'nd' (newdir?) alias that calls this python script:

https://github.com/danwills/shell-scripts/blob/bb989985d270c...

This makes all directories with names provided by args, including spaces and multiple levels (slashes) at once. It then enters the resulting directory as well (when aliased including 'cd' as advised in the comment).


  # create a directory in the current directory and cd to it

  function mkcd() { mkdir -p "$@" && eval cd "\"\$$#\""; }


Why the eval? This works fine for me:

  mkcd(){ mkdir --parents -- "$@" && cd -- "$@"; }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: