Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Open a new tab in Iterm2 with current directory
# Add these functions to your Bash profile.
# Copies the current directory to the clipboard
function cwd {
pwd | pbcopy
}
# Changes the current directory, after new tab has been loaded
function chwd {
DIR=`pbpaste`
cd $DIR
}
# Copies directory to clipboard, opens new tab and cd into new directory
function nt {
cwd
osascript -e 'tell application "iTerm" to activate' -e 'tell application "System Events" to tell process "iTerm" to keystroke "t" using command down' -e 'tell application "System Events" to tell process "iTerm" to keystroke "chwd"' -e 'tell application "System Events" to tell process "iTerm" to key code 52'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment