Simple I am looking for a way to map a keyboard key to a unix command. It could be as simple as literal as opening up terminal and pasting a required bit of text.
Asked
Active
Viewed 796 times
1
2 Answers
1
You could use a tool like Keyboard Maestro but it might be a bit overkill.
If you just want to execute a command in Terminal and close the window again:
- Put command in a shell script
- Make it executable (
chmod +x ...
) - Move shell script to a convenient place (e.g. our Desktop)
- run shell script/command by double click

nohillside
- 100,768
-
I just want to run a command (eg pwd) in terminal via a keyboard key. When you press the key it could open terminal and paste in PWD and then close terminal, but this would be sloppy. – ThomasReggi Oct 09 '11 at 20:52
-
Maybe a shell script is ok then, I've extended the answer accordingly. – nohillside Oct 10 '11 at 06:09
-
there is the unix alias command. i have the h key set to type out my help.txt file. alias h='cat ~/help.txt'; alias ll='\ls -albhFG'; alias ls='ls -FhG'; alias more='less'; alias mv='mv -i'; alias rm='rm -i'; alias top='top -o cpu'; You need to press return, but one letter commands are not too bad. – historystamp Feb 20 '19 at 06:30
0
Automator has a "Run Shell Script" action.
- Open Automator and create to new Quick Action
- Search for
shell
in the actions menu - Drag "Run Shell Script" to the right panel
- Save as "Run Unix command"
- Open Keyboard and go to Shortcuts
- Scroll to "Services" and scroll to the bottom
- Bind "Run Unix command" to whatever you want.

idbrii
- 243
l
but rather runsudo rm -Rf /
– Daniel Feb 09 '12 at 01:30