Wednesday, October 28, 2009

Command-Line Editing








 

 










Command-Line Editing



Line edit mode is a feature of the shell that allows you to edit a command line using built-in commands that mimic those found in two popular screen editors. The POSIX standard shell provides the capability to mimic vi; however, both Bash and the Korn shell also support an emacs line edit mode. We list the complete set of vi commands in Table A.4 in Appendix A, "Shell Summary."



If you've used either of these screen editors, you'll find that the built-in line editors in the shell are faithful reproductions of their full-screen counterparts. If you've never used a screen editor, don't be intimidated. This capability is one of the most useful features in the shell. In fact, after learning how to use one of the shell's built-in editors, you'll be able to learn vi or emacs with little effort.



To turn on a line edit mode, you use the set command with the -o mode option, where mode is either vi or emacs:





$ set -o vi Turn on vi mode



Note that you can put this in your .profile or ENV file to automatically start up the shell with one of the edit modes turned on.












     

     


    No comments:

    Post a Comment