Set the default directory in mac terminal

后端 未结 6 1922
天命终不由人
天命终不由人 2020-12-23 09:00

I only use terminal (mac) for git, and I only use git for one directory. Is it possible to set the default directory (the directory when terminal is opened) to the directory

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 09:42

    I modified @Michael Ozeryansky's answer to solve the caveat he mentioned:

    The only caveat is if you're in your actual HOME directory and open a new window, it will take you to START. Which is expected.

    To make your second terminal window tab starts from the Home or Any other dir:

    export START="/Users/michael/my/starting/directory"
    export DIR = "path/to/directory"
    if [[ $PWD == $HOME ]]; then
         cd $START
    else 
         cd $HOME  // or any other dir: cd $DIR
    fi
    

提交回复
热议问题