WezM.net The weblog of Wesley Moore

17Aug/095

Idea: Adaptive shell

I had an idea today when navigating around in the shell. All my work related files are stored in ~/Work. Under that there's a folder for each project. Sometimes there are multiple variations on a project or project with a similar prefix such as:

  • radiopaedia
  • radiopaedia-stable
  • radiant-sites

When I type rad [Tab] in my shell (zsh) it kindly completes this to radi and gives a list of the other completions since there are several to choose from. I though it would be nice if the shell could learn from the choices I make. So if I generally choose radiopaedia then rad [Tab] would complete to radiopaedia but still show the list of option.

I'm sure there are several other areas where an adaptive shell that learnt from usage patterns could be applied.

Related Posts

Comments (5) Trackbacks (0)
  1. You might be able to do something like this with bash-completion, but I think that’s more about arguments. Eg:

    $ ls
    blah.mid blah.pdf
    $ evince [TAB]
    $ evince blah.pdf (chooses PDF since it’s evince)

  2. I was using bash for a while but switched to zsh because it has more smarts. It does the completions based on argument including hostnames for ssh and remote path completion for scp. However in the example above all the arguments are directories and are therefore valid arguments to cd or similar.

  3. From the zsh FAQ:

    4.5: How do I get started with programmable completion?

    The main resource is the zshcompsys manual page. It’s complicated,
    I’m afraid, far too much to go into here. See also the user guide
    referred to above, or copy one of the very many existing functions. For
    a professionally produced guide, see the book ‘From Bash to Z Shell:
    Conquering the Command Line’ by Oliver Kiddle, Jerry Peek and Peter
    Stephenson (me), published by Apress, ISBN 1–59059-376–6. Chapter 10
    tells you how to configure the completion system and chapter 15 how
    to write your own completion functions.

    Looks like you could use a temp file that saves your last completions, and run a perl command or something over that file, using the ‘command’ option to zsh’ completion system.

  4. How about this: http://wiki.github.com/joelthelion/autojump
    I found this when looking for something else and it reminded me of your post. I haven’t tried it though.

  5. Thanks Hamish that looks like it could be quite handy. I’ll give it a try.


Leave a comment


No trackbacks yet.

Recent Comments

Categories

Links

Archives

Tags

adaptive atom awk bash benchmark books cake consolas core-audio debian decoder delivery expand feed font fonts git glob gripe installer iPhone ipod Linux mad melbourne microsoft mp3 mpg123 music package pocket-reference rss ruby script sed shell smoothing snow-leopard textmate title tux UNIX uri-scheme variable virtualbox

Meta

Contact