Desktop Shortcut to Terminal at a Specific Directory?

1

1

What I need is an icon on my desktop that I can double-click, and launch terminal, but already cd'd to specific directory.

I know how to configure Terminal.app to automatically cd to a specific directory on launch; I would like a quick way to launch into one of many directories (to work on one of several git repositories without having to navigate up and down the file system).

I tried creating a text file containing the following shell script:

cd /Users/me/MyFolder

and saving it with the name and extension GoToDir.command.

However, when I double-click on the file, Terminal launches with this contents on the console:

Last login: Mon Aug 28 20:14:31 on ttys000
Machine-Name:~ username$ /Users/username/Desktop/GoToDir.command ; exit;
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

...and input is disabled. Clearly, this .command is run as a one-off program that terminates, and that's it.

How do I keep the console "alive"?

Nicolas Miari

Posted 2017-08-28T11:24:20.017

Reputation: 113

Answers

1

I use "ShellHere". The feature that I like about this one compared to others I tried (don't know about Go2Shell, also recommended here), is that if the selection in the front Finder window is a folder itself, Terminal will "cd" into THAT folder. This usually save me an extra double-click in the Finder or an extra "cd" in Terminal.

If there is nothing selected in the window (or if the selection is a file, not a folder), Terminal will open the folder/directory of the Window itself.

jimtut

Posted 2017-08-28T11:24:20.017

Reputation: 832

I downloaded it but am unable to install it (Finder toolbar does not accept drag and drop). – Nicolas Miari – 2017-08-29T04:57:55.660

1Looks like you need to hold the Command key down to drag into the toolbar now. – jimtut – 2017-08-29T11:15:55.483

Oh, thanks! It's working now. Too bad the icon hasn't been updated to match the current look of Finder... – Nicolas Miari – 2017-08-29T11:26:15.663

1Glad it works. You should be able to assign any icon you want to the original ShellHere program (Finder -> Get Info). You might need to remove/replace the icon in the toolbar to get it updated there. – jimtut – 2017-08-29T15:04:42.623

2

There is an app, "Go2Shell" that puts an icon in a finder window. Click the icon and it opens a Unix terminal for the directory that the finder window is displaying. Works seamlessly and I find it very useful. It's a free app available from the app store.

jmh

Posted 2017-08-28T11:24:20.017

Reputation: 231

Hmm, it works. I need to make a separate copy of the app on each directory I want to shell into. I can even make a shortcut of that app copy in my Desktop and launch fom there. However, it doesn't seem to respect my selected Terminal profile, and always launches in "Basic"... – Nicolas Miari – 2017-08-29T05:05:33.123

Thank you for your answer. I am accepting jimtut’s one though, because the app he suggested seems more elegant to me (e.g., had to add *.app to my .gitignore after copying Go2Shell to my repo’s directory). – Nicolas Miari – 2017-08-29T23:42:17.497

You've already selected so this is just free info. Go2Shell lets you select using terminal, iterm2 or some other terminal program. I use iterm2 and it uses my pre-defined set up for how the window looks. That may interest you or not. – jmh – 2017-08-30T01:15:11.200