As I've written numerous times that I'm a keyboard person and a heavy Alfred app user.
I'll often run shell commands by using Alfred's ! feature. E.g. typing !ls -l will open a new tab in Terminal.app and run ls -l in it. Most of the time though, I just want to run the command and don't care about the results. The default behavior which switches to Terminal.app and opening a tab to run the command throws my focus away from the job at hand.
It turns out that we can do something about it.
Before we start, do this:
- Run this in Alfred
!ls -l ~/.profile
. - Check if the Terminal output says “No such file or directory”. If it says that, use (5a) instead of (5b) below. If it doesn't say the file is missing, use (5b) instead of (5a) below.
Now do this:
- Open Alfred Preferences (type alfred into Alfred!)
- Click Features
- Click Terminal / Shell
- Click the dropdown beside Application and choose Custom.
5a. Paste the following into the text box:
on alfred_script(q)
do shell script & q
end alfred_script
5b. Paste the following into the text box:
on alfred_script(q)
do shell script "source ~/.profile; " & q
end alfred_script
Once you have done this, running shell commands with Alfred will no longer open a terminal tab. (Naturally, if there's an error in your shell command, you wouldn't be notified)
Tweet Buffer