Jump to content

Open a new Terminal window of type ['Basic', 'Grass', 'Homebrew', etc..]


hroe

Recommended Posts

alfred2-NewTerminalWindow


Alfred2 workflow to open a new Terminal.app window of type ['Basic', 'Grass', 'Homebrew', etc..]

Installation

 

Download current version from here

 

Usage

Type `nt` to see a list of available types of Terminal.app windows to open.

Select the one you want with ⌘-[#] or arrow keys and then Return.

Or, restrict the list with a minimum match, e.g. `ntg` will show all options starting with a *g*.

Screenshots
 

alfred2-NewTerminalWorkflow-screenshot1.
alfred2-NewTerminalWorkflow-screenshot2.


Extending to additional Terminal.app window profiles

The list of offered terminal types is gathered from screen snapshots sitting inside the workflow. The names of the snapshots must match exactly (spaces and capitalization) the menu item in Terminal, e.g. to get the Red Sands profile the screenshot file should be named `Red Sands.png`. (If you need to manipulate the files on the command line, recall that spaces need to be escaped as `"\ "`.)

To remove options, simply remove the appropriate *png* file from the Workflow directory.

To add options, open a new terminal window of the new profile, take a screen snapshot (⌘-4 followed by space bar followed by clicking on the window; the screenshot will then be on your Desktop). Rename the screenshot as above and move to the Workflow directory.

Though not necessary, you can compress your new screenshots by going into the workflow folder and running the following on the command line. This reduces the ~110-120K screenshot files down to ~5K.

find . -size +30k -and -name "*.png" | xargs -I {} convert -scale 200 {} {}

Because these screenshots are being used for tiny icons, this compression is just fine and probably could be to even much smaller sizes.

Link to comment

Im a new Alfred user, and this is really cool.

 

I have just one question for this workflow.. :   How can I get the terminal window to be active after Ive used alfred starting it ?   I have to  Cmd - Tab to switch between active applications.. 

 

Thanks.

 

Looking back at the script I realized that I had left in a line of code I was using during development to output the intermediate step to a file.  I've fixed that and uploaded a new version.  However, with some quick testing I don't think that is related to your issue.  

 

I'm surprised that the workflow isn't leaving you with Terminal.app active.  The script sends an `activate` to Terminal.app before it selects the desired menu item and it works correctly for me.  If you figure out a solution I'd be happy to update the github workflow.

 

Sorry I can't be more help.

 

cheers,
-Henry
Link to comment

The only thing I didn't like was that the keyword didn't have a space after it. I'm sure others like it without the space but I guess I'm a little OCD or something lol.

 

I can understand that.  My own preference is minimizing keystrokes, so I prefer not having the space.  Thankfully that's an easy one to customize.  (I find myself making that small modification to numerous workflows I've downloaded from this forum, so I'm guessing I'm in the minority on that one.)

 

cheers,
-Henry
Link to comment

I'm surprised that the workflow isn't leaving you with Terminal.app active.  The script sends an `activate` to Terminal.app before it selects the desired menu item and it works correctly for me.

 

One quirk that I've found with `activate` before is that you sometimes need to repeat the `activate` statement, so you just have the exact same line twice. This happens sometimes in some cases for some people. I don't have a good explanation why it does, and the repeated statement feels a bit hacky, but it seems to take care of the problem often.

Link to comment

One quirk that I've found with `activate` before is that you sometimes need to repeat the `activate` statement, so you just have the exact same line twice. This happens sometimes in some cases for some people. I don't have a good explanation why it does, and the repeated statement feels a bit hacky, but it seems to take care of the problem often.

 

Thanks for the tip.  I've added an additional "activate" after the opening of the new Terminal window.  Hopefully this fixes the problem NickeZ28 was having.

Link to comment

Thanks for the tip.  I've added an additional "activate" after the opening of the new Terminal window.  Hopefully this fixes the problem NickeZ28 was having.

 

For me it still opens in the background.. leaving me with whatever application I have running while toggling alfred, and running the "nt" command..  weird.. maybe Im doing something wrong.. beeing a newbie at this and all.. 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...