Opening a new terminal tab in OSX(Snow Leopard) with the opening terminal windows directory path

前端 未结 5 823
难免孤独
难免孤独 2021-02-01 20:37

I\'ve been Googling for a while looking for a simple way to do this, and I can\'t find one.

I have a custom terminal environment set up (zsh) with various aliases and fu

5条回答
  •  情歌与酒
    2021-02-01 21:13

    I have a couple of scripts I use:

    dup (New window with the working dir):

    #!/bin/sh
    pwd=`pwd`
    osascript -e "tell application \"Terminal\" to do script \"cd $pwd; clear\"" > /dev/null
    

    and tup (New tab with the same working dir):

    #!/bin/sh
    
    pwd=`pwd`
    osascript -e "tell application \"Terminal\"" \
        -e "tell application \"System Events\" to keystroke \"t\" using {command down}" \
        -e "do script \"cd $pwd; clear\" in front window" \
        -e "end tell"
        > /dev/null
    

提交回复
热议问题