Alias which runs terminal command

Posted:
in macOS edited January 2014
I think this is the right forum because it is built into OS X and does not need a 3rd party app.



Anyway, on my old computer I had an icon that I clicked on, it opened terminal and then it ran the command and left it open. It was my old computer which I erased since then, but I do not remember how to that.



Does anybody know how to do this?



Thanks.

Comments

  • Reply 1 of 3
    MarvinMarvin Posts: 15,326moderator
    You would create a plain text file in TextEdit, type in the command you want to use. Then save it with a .sh extension - it will ask to put .txt but just use .sh. Then in a terminal make it executable by typing:



    chmod 755 <drag .sh file here>



    and hit return. If the .sh file is not set to open in terminal, use get info to set this. Now when you double-click the .sh file, it will run the command in a terminal and leave it open.
  • Reply 2 of 3
    endymionendymion Posts: 375member
    Alternatively you could use OnMyCommand which is a very flexible system for triggering terminal commands. You can even download pre-built terminal commands.
  • Reply 3 of 3
    Thanks Marvin. That worked. I had thought i tried that but I guess not.
Sign In or Register to comment.