This article describes common functionality that is often thought lacking in ksh but is just hiding in unintuitive corners (such as command line completion!)
My preferred shell is bash but I often find myself on ksh because it is the default shell on Sun boxes. It has always drove me insane trying to remember how to accomplish very simple things like scrolling through history in ksh. Hopefully by writing it down I will remember or at the very least have a place to go look it up without searching google.
Command Scrolling
Command scrolling is the trick whereby you can scroll through previously typed commands in your shell history. In bash this is a simple matter of using the arrow keys. Unfortunately, ksh is not so intuitive.
Note that the following are based on vi mode editing. Thus, the following command must be in your .profile to work:
export VISUAL=vi
If you wish to use emacs commands for editing then you are on your own
- Press the
Esckey - Press
kto scroll back through the history list - Press
jto scroll forward through the history list
Command Editing
Editing the command line is identical to using command scrolling and without going through every vi command possible here are some basics:
h= scroll leftl= scroll right^= move to beginning of line$= move to end of linei= inserta= appendx= deletedw= delete wordcw= change word
Command Line Completion
The command line can be much faster than a GUI interface if you know what you are doing and one of the greatest productivity boosters is command line completion. Most decent shells provide a way of doing predictive completion on commands, filenames, and pathnames. In the bash shell this is accomplished by hitting the Tab key and the shell will complete the word you are typing to the best of its ability. In ksh command line completion is accomplished by doing the following:
- Press the
Esckey - Press the
\ - Press the
-to see a list of all possible completions