Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use aliases as a command memory aid UNIX
I assume most people who use the Terminal know about using aliases in the shell to save typing. There have been several previous hints about this (1, 2). I use aliases to store reminders of infrequently used commands and options as much as I do to save typing. When I find out how to do something, I make an alias for it and add a comment line explaining what it is good for.

Read the rest of the article for more details on using the alias file to remember commands...

I keep all my aliases in the file .aliases in my home directory and 'source' this file at the end of my .tcshrc file. It is also possible to keep your aliases in a file named aliases.mine in the ~/Library/init/tcsh folder as has been discussed in previous hints. Since all my aliases are in the one file, I can remind myself of commands by looking through that file for keywords. And of course, I have set up an alias to do this:
# showalias: to remind yourself of an alias (given some part of it)
alias showalias 'grep \!$ ~/.aliases'
Note that this will show me keywords in the comments as well as in the aliases themselves. This makes it more effective than merely using the 'alias' command which lists the current aliases. Some examples:

I wonder what socket connections exist, so I remind myself of how to find this out by doing:
 % showalias sock
This outputs:
 # lsock: to find open sockets
alias lsock 'sudo lsof -i'
I hear some disk activity and wonder which application is accessing the disk, so I remind myself of how to find this out by doing:
 % showalias disk
This outputs:
 # filewho: to show file system usage (to see what is causing disk activity)
The above two examples make use of info gleaned from previous hints. Note that in the second example, the keyword ("disk") I searched for was not part of the alias itself, so I just got the comment line - which was sufficient to remind me since it included the name of the alias. (By the way, that alias is: alias filewho 'sudo fs_usage')
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)

Use aliases as a command memory aid | 3 comments | Create New Account
Click here to return to the 'Use aliases as a command memory aid' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Your .aliases file
Authored by: nevyn on Jul 07, '02 09:01:54AM

Couldn't you, like, post your .aliases file here? It sounds like it has a lot of usable goodies in it :)

[ Reply to This | # ]
My aliases file
Authored by: hayne on Jul 17, '06 09:05:02AM
I have posted my (updated for use with Bash instead of Tcsh) aliases file on the forums:

[ Reply to This | # ]
showalias for Korn Shells
Authored by: pzwack on Aug 26, '02 04:05:21AM

If the alias doesn't work for you, you may be using one of the "other" shells around, like ksh, zsh or bash (new in Jaguar).
Those don't allow arguments to aliases, use functions instead:

# showalias: to remind yourself of an alias (given some part of it)
showalias() { grep ${1:-showalias} ~/.alias }

If you don't give an argument, the showalias lines themselves are shown.

[ Reply to This | # ]