Advanced Terminal / Console apps for Mac OS X?

1

1

I use a lot of command line programs, very often with similar arguments. Can anyone recommend an application or a workflow that allows me to store often used shell commands and search through my recent commands, using a GUI?

I have commands that I use very often (eg. rsync a specific directory to a server) and other commands that I use less often. Creating shell scripts for every code snippet I might reuse seems a bit awkward.

Especially for programs that I use seldomly, I end up reading the docs over and over again, because I forgot to write down the exact shell command. Ideally I would like an app that's just like Terminal.app, but provides some kind of history and snippet management.

What do you use to keep track of shell commands?

Jakob Egger

Posted 2011-01-03T21:32:46.270

Reputation: 271

Also, regarding the "Terminal GUI", for terminal/bash lovers, that's one of the mortal sins. Why click when you can type? I'd wager there's just no big enough market for that. – Daniel Beck – 2011-01-03T21:59:17.080

Answers

5

Answering to the best of my knowledge. I'm not sure what you think is missing, so i can be waaaay off there. In that case, just tell me.


Terminal (more specifically, bash) has history. press Up-Arrow or (afterwards)Down-Arrow, or enter history. It's stored in ~/.bash_history which can be read by any text editor. Editing commands is easier if you know the key combinations for navigating.

History search might also help you to find specific parameter sets for a single call. For example, enter hdiutil and use these to find all recent invocations of that command, and cycle through them.

These (1, 2) commercial screencasts might also help you to learn more about your shell. I bought and like them, but there are tons out there explaining almost any aspect of Terminal or bash usage.

Tools like AppleScript (tell application "Terminal" to do script "...") and Automator (Run Shell Script action) might also help you to automate repeated tasks, or create "macros".

In case of often executed programs, creating a small shell script wouldn't be a bad idea. It's essentially a two-liner, and using an editor such as TextMate, with commands related to what you want to accomplish (e.g. "make executable", so you don't have to type that chmod line) makes it even easier.


Mac OS X uses the .tool and .command file extensions for scripts to be executed using Terminal. You need to make them executable, unfortunately.

Daniel Beck

Posted 2011-01-03T21:32:46.270

Reputation: 98 421

Thanks alot! I'll have a go at the history search, might be just what I want. – Jakob Egger – 2011-01-04T09:20:14.657

1

In addition to the tips that Daniel gave you, here are a few more:

  • You can set HISTSIZE and HISTFILESIZE higher than their default values of 500 entries. This will allow you to keep more history.
  • Create aliases and small functions when it doesn't make sense to create a script. These can be stored in your ~/.bashrc file and they'll always be available or you can put them in a separate file and source them from within ~/.bashrc or even from the command line if you don't always need them immediately.
  • Use some sort of logging. My history logging functions keep not only the commands and arguments, but the date and time (which Bash history can do, too) and can keep the directory that was current when the command was issued as well as the terminal or IP address and other information you choose (for example, since I use more than one version of Bash, I have mine log the Bash version).
  • You can bind keyboard macros to function keys or other key combinations that allow you to cut down on repetitive typing.
  • You can set variables to do the same thing.

Paused until further notice.

Posted 2011-01-03T21:32:46.270

Reputation: 86 075

Thanks for the HISTSIZE tip. I already use some aliases, but for most commands I just don't bother creating aliases, because I don't use them often enough... – Jakob Egger – 2011-01-04T09:25:44.870