Skip to content

Instantly share code, notes, and snippets.

@leminh111
Forked from drewthorp/tab.fish
Created June 1, 2018 07:11
Show Gist options
  • Save leminh111/5a1004e1e2b1e594674100ff6c33f3d8 to your computer and use it in GitHub Desktop.
Save leminh111/5a1004e1e2b1e594674100ff6c33f3d8 to your computer and use it in GitHub Desktop.
Fish shell function to open a new tab in OS X terminal and run a series of commands. Usage tab cmd1 cmd2....
function tab
set -l ascmd "osascript -e 'tell application \"Terminal\" to activate' -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down'"
for arg in $argv
set ascmd "$ascmd -e 'tell application \"Terminal\" to do script \"$arg\" in selected tab of the front window'"
end
set -l ascmd "$ascmd;"
eval $ascmd
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment