LoginSignup
1
1

More than 5 years have passed since last update.

mkdir したディレクトリに cd する

Last updated at Posted at 2013-10-04

こういうのはよく見掛けるけど、 mkdir のオプションが固定だったり、
- で始まるディレクトリが扱えなかったりして悲くなったので作ってみた。
(ってのは後付けで、とりあえず Qiita に何か書いてみたかった)

function mkcdir() {
    mkdir "$@" || return $?

    local arg got_end_option=0
    for arg in "$@"; do
        case "$arg" in
            --)
                got_end_option=1
                continue
                ;;
            -*)
                ((1 == $got_end_option)) && break
                continue
                ;;
            *)
                break
                ;;
        esac
    done
    cd -- "$arg"
}
1
1
2

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
1
1