Monday 15 October 2007

Interactive shell

I work entirely in the shell. I don't really need more :) But I spend most of mine time typing ls, emacs [somefile], mv this rm that and lots of less. Further I repeat a lot of commands, especially when I am programming. Some stats out of my .bash_history. (1000 lines)
63 x make
159 x ls
22 x rm
101 x cp
42 x emacs
25 x less
$cat .bash_history | sort | uniq | wc
359
from 1000. So 641 commands are repeated.

You get the idea. So I am a computer programmer, I am lazy, what I can I do against this?
Create an interactive shell.
The shell sits there and waits. As soon as you hit any key (not Enter or Space) it goes into a special configured mode. And then does appropriate. So if I want to ls a dir, I just type 'l' and then this resolves to ls. If I want to edit a file I type 'e' and then the file name.
This is in somewhat different to alias. As you don't have to hit space. A little example:
I want to edit a file:
bash : em [TAB] [SPACE] file [ENTER]
alias : e [SPACE] file [ENTER] (assumeing alias e=emacs)
dash : e file [ENTER]

Further you can suggest auto completion based on what you normally type. If you have completed a command and you hit enter again it will just repeat the command. This should get rid of about 80 % percent of the stuff I type into the shell.

In 1000 shell commands I had to type a space after 756 commands. (Remember 159 are only ls)
$cat .bash_history | grep -E "[a-zA-Z] ." | wc -l
756


If you hit space you will drop down to normal bash. So you can start creating the wonderful piped commands.

3 comments:

William French said...

Ok didi im confused

whats wrong with "alias"

vext01 said...

whats going on here?

vext01 said...

look at alias or tab completion?