zsh tab complete . to ./

Great challenge! Try this on the commandline, if it works add it to ~/.zshrc

bindkey '^I' dotcomplete
zle -N dotcomplete
function dotcomplete() {                                        
  if [[ $BUFFER =~ ^'\.'$ ]]; then
    BUFFER='./'
    CURSOR=2
    zle list-choices
  else
    zle expand-or-complete
  fi
}                    

It adds a function which runs every time you press TAB (^I). If the the line you've currently typed only contains a dot (^=beginning of line, '\.' =super-escape the dot, $=end of line), then replace that dot with a ./ then continue with the normal completion.

It doesn't exactly do what you ask, which is to treat the dot as the current directory. But it will save you they keystrokes you want to save.

Tags:

Zsh

Oh My Zsh