Open -a "Terminal" this, I can now type > new Projects/desktopprĪnd get a new Terminal window there. I created this function in my shell configuration file ( bash, zsh): # creates a new terminal window Use the fi command in the Finder to create a new window (multi-tab) in the terminal, and then enter the current path. This is already really close to what I wanted. printf -v args 'q ' '', if you want to generate your arguments in eval-safe form.Otherwise, you're inviting bugs - local args'' flattens the original array into a string, and a string can't store array boundaries in a safe way without escaping. Will open a new Terminal window with ~/Documents as the working directory. Select one or more folders, libraries, or drives you want to open in a new tab, click/tap on the File tab on the menu bar, click/tap on the arrow to the right of Open new window, and click/tap on Open new tab. Enter the open commandĭuring those web searches, I also found suggestions to use the open command, instead: > open -a Terminal ~/Documents Open Folder, Library, or Drive in New Tab from File Menu in File Explorer. (No UI Scripting solutions – those have their own issues.) I have a few other ideas where this might come in useful. If you know of a better way to create a new Terminal window or, even better, a Terminal tab with AppleScript, then please let me know. (Not to be confused with do shell script.) So this AppleScript, sort of does what I want, but seems cumbersome. Stack Exchange Network Stack Exchange network consists of 180 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. You can create a new Terminal window with AppleScript using the do script command in the Terminal dictionary. I tried Open a new tab in the same directory answer but still can't get the directory working. This is something that really annoys me when working on machines owned by other people who dont have. Make sure the focus is in iTerm when you do this: The script should run and you should see a new tab open. To launch it, enter Cmd + Shift + O, then start typing the name of the script, when its highlighted, hit Enter to run it. The make new window or make new tab commands fail with errors and I have tried several combinations.Īfter some web searching, it looks like this has been broken for a long time. Set any new tabs to be in the current working directory. There are several different ways to run a script but the easiest is to use the 'Open Quickly' window. Unfortunately, this particular piece of the AppleScript dictionary is broken. > new ~/Desktop # opens a new terminal window at ~/DesktopĪfter my last success using AppleScript, I thought this would be the best solution again. What I want, is a new window that defaults to current working directory or a custom directory that I can provide with an argument: > new # opens a new terminal window at the current working directory New windows created with the keyboard shortcut or from the menu will always have the home directory ~ as the current working directory. But in some cases, it can be more useful to use a shell command. Of course, you can easily create a new Terminal window from the ‘Shell’ menu or by using the ⌘N (or ⌘T) keyboard shortcut.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |