Jump to content
politicus

Setting the Terminal/Shell to "Custom" (iTerm).

Recommended Posts

I want to be able to launch some zsh/bash commands from the Alfred's bar. 

 

I sat the prefix to my likings, selected "Custom", modify the script accordingly. 

 

on alfred_script(q)
	tell application "iTerm"
		activate
		do script q
	end tell
end alfred_script

 

But it doesn't work.

Share this post


Link to post

@Andrew Thank you.

Unfortunately there is no script for the iTerm version I do have (3.1.5).

I tried using the script for the 2.9 version but it didn't work. 

I will have to keep iTerm 2 open :)

Share this post


Link to post

I installed the latest beta version of iTerm 2 (Build 3.3.5beta1), and now my modified version of @Andrew's custom script isn't working. I think the only thing I changed was line 9 [set onlywindow to false], and this made my query always open in a new tab in iTerm. But now it seems, I get a new tab, but my query doesn't make it there. Maybe I just need to incorporate a pause or something? It feels like it's just moving too quickly for the new tab to keep up.

 

Prior to this new beta version, the new tab method was working well.

on alfred_script(q)
	if application "iTerm2" is running or application "iTerm" is running then
		run script "
			on run {q}
				tell application \"iTerm\"
					activate
					try
						select first window
						set onlywindow to false
					on error
						create window with default profile
						select first window
						set onlywindow to true
					end try
					tell the first window
						if onlywindow is false then
							create tab with default profile
						end if
						tell current session to write text q
					end tell
				end tell
			end run
		" with parameters {q}
	else
		run script "
			on run {q}
				tell application \"iTerm\"
					activate
					try
						select first window
					on error
						create window with default profile
						select first window
					end try
					tell the first window
						tell current session to write text q
					end tell
				end tell
			end run
		" with parameters {q}
	end if
end alfred_script

 

Share this post


Link to post

For anyone landing on this thread: the previous iTerm scripts have changed ownership (disclaimer: I’m the new author) and have been rewritten from scratch, so if you have any issues try the newer versions.


You can find them on the new repository, or by using the old links as they will redirect to the new one.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...