views:

112

answers:

6

we all create/discover new and useful commands every day (I do...) but I forget them the day after, above all those complicated command pipes.. I use history | grep but that's not enough.

I'd like a program to save and categorize my favorite commands, that lets you search them and execute them easily.

If you know any, that'd be cool if not, I'm writing one.. don't you thing this is a good idea?

A: 

On windows: Slickrun helps here. I put all my shorcuts and commands in here and I attach it to the WIN-R key so I can get to them easily! See here : http://www.bayden.com/SlickRun/

Preet Sangha
oh yeah that was cool.. when I was on windows! But now I've been using OS X / Linux for a few years and slickrun is definitely not enough to get me back =)
luca
+1  A: 

I personally would get a basic quick reference sheet in digital format and add my own to it as I go (under the groupings they have if it fits or creating a new group). If using a GUI shell I would make it my desktop, otherwise I'd periodically print it out.

Much simpler to create and use, and wastes a lot less time.

Luke Schafer
this is why I disagree: a command I use quite often is this one:
luca
svn status | grep "^\?" | sed -e 's/? *//' | sed -e 's/ /\\ /g' | xargs svn addI don't want to always have to copy, paste it and execute it.. it should be fast!Another problem is that many times I'm lazy and I don't write anywhere these commands... if the system was integrated with the command line it would be easier to fit in my workflow.
luca
Ok, good call. Maybe the best thing would be to alias that and put the alias on your quick reference sheet :)
Luke Schafer
+1  A: 

Pressing Ctrl + R in Bash lets you search command history backwards and execute matching commands.

Alan Haggai Alavi
+2  A: 

Add the following lines to your .bashrc:

export HISTFILESIZE=100000
export HISTSIZE=100000

Now you can find all your old commands using CTRL+R, or by opening ~/.bash_history.

If you want to document some more complex combinations, add them as functions in your .bashrc:

# find uncommitted files which have TODO in them, but not in html files
uncommitted_todo_not_html() {
    grep -n TODO $(hg st -n | grep -v '\.html')
}
too much php
Cheers for this - I never knew about this...
Preet Sangha
A: 

OK, I'm writing one!

It's a simple ruby script, commands are saved in a yaml file, each one with a title, description and the actual command.

maybe I'll post it somewhere if it gets usable. The biggest problem is executing commands: I want to execute them in the current shell, and maybe be able to edit them before executing, so only way is to copy and paste them in the same terminal.

I'm automating that with osascript (applescript) therefore it'll work only on OS X.

thanks to you all

luca
A: 

I'd just use alias and store them in ~/.bashrc or ~/.bash_profile.

If you need to remember your aliases you could comment the alias entries with # and alias a command to list them.

# list my aliases
alias lscmds='grep alias ~/.bashrc'
agtb