If you spend a lot of time at the *nix command line, you probably use your shell history quite a bit to avoid typing commands in over and over. Or maybe you define shell aliases for your most precious incantations. Shell history is great, and I have mine set to save a bajillion entries, ‘cause we have more than 640k these days. But even with a nearly infinite shell history, I find myself wanting to know what are the few important commands I usually need in the specific directory I happen to be in.
Frequently Used Commands (fuc)
So, this little shell script will let you save off the important commands to a
.fuc file in the local directory, and then easily recall those commands in a little menu.
Let’s say you are working away, and you want to remember a particular command:
Which will save the command to the
.fuc file, and also run it. Later, you can just type
fuc from the same directory, and get this:
1 2 3 4 5 6
What I really wanted to do was put the selected command on the command line, ready to be edited, then hit enter to run it. But I couldn’t be bothered to figure out how to do that. So selecting a command just runs it immediately.
(I know there are a lot of much more complicated implementations that tweak your actual command history to be directory-specific, but I wanted to be able to specify which commands were the important ones, and just remember those.)
Here is the script. Put this somewhere in your path, and name it
fuc, or if that’s too NSFW than I’m sure you can come up with a better name. Maybe
dangit or something.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24