Open multiple new terminal tabs on OSX using the current working dir


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # Open a new tab on OSX Terminal with the current working dir.
  2. # Optionally, pass the number of tabs as parameter.
  3. #
  4. # Example:
  5. #
  6. # cd /my/very/long/path/and/i/dont/want/to/repeat/myself
  7. # nt 10
  8. #
  9. # You should add this to your ~/.profile
  10. #
  11. function nt {
  12. if [ $# -ne 1 ]; then
  13. TIMES=1
  14. else
  15. TIMES=$1
  16. fi
  17.  
  18. osascript -e "
  19. repeat $TIMES times
  20. tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down
  21. tell application \"Terminal\" to do script \"cd $PWD; clear;\" in selected tab of the front window
  22. end repeat
  23. " > /dev/null 2>&1
  24. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.