2

I have an issue with zsh (or oh-my-zsh):

When I want to run a script in current directory, I do ./script.sh. In bash I could do .<TAB> and it would give me ./ where I could continue typing the script name ./sc<TAB> which would end up with ./script.sh

Now the problem is that when I do .<TAB> in zsh, I get a list of alternatives where none of them are ./.

The reason I'm not just typing ./ is that it's quite cumbersome on a Norwegian keyboard layout: . then SHIFT+7. Makes me feel inefficient :)

I've tried with zstyle ':completion:*' special-dirs true and some options like

setopt autolist
unsetopt menucomplete `

But nothing seems to work for me.

I'm quite new to this, so I'd really appreciate any help solving this!

1
  • I know this annoying SHIFT+7 too well... some time ago I mapped one of these useless windows keys ;) to /. Since then it's real fun to type //////////. Perhaps that's an option for you, too.
    – mpy
    Apr 2, 2014 at 17:13

1 Answer 1

1

I don't know how to tweak the completion system, so that it expands . always to ./. But here is a workaround for the special case you have described, i.e. at the beginning of the command line:

expand-or-complete-special-dot() {
  if [[ $BUFFER == "." ]]; then
    LBUFFER="./"          
  fi 
  zle expand-or-complete
}
zle -N expand-or-complete-special-dot
bindkey "^I" expand-or-complete-special-dot

This is a wrapper for the normal expand-or-complete function which is (by default) bound to TAB.

1
  • Brilliant! This is exactly the behaviour I want :)
    – Paaske
    Apr 4, 2014 at 9:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .