Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert slash (/) as a result of tab-completion after two dots (..) #3775

Closed
danielfernandez opened this issue Apr 15, 2015 · 14 comments · Fixed by #6803
Closed

Insert slash (/) as a result of tab-completion after two dots (..) #3775

danielfernandez opened this issue Apr 15, 2015 · 14 comments · Fixed by #6803

Comments

@danielfernandez
Copy link

When using other terminals, if I want to write a path like e.g. ../somefolder I'm used to doing:

$ ..(tab!)somef(tab!)

This works perfectly like that in CYGWIN, MINGW32 or the GNOME Terminal with bash, but that ..(tab!) doesn't work on oh-my-zsh on iterm2 on Mac OS X Yosemite because the tab key does not automatically complete the slash / symbol after ..

I know it might seem a very small detail, but I'm so used to that it really bugs me having to reach the real / key, especially in non-American keyboards where it does not have a dedicated key (for me, on a Spanish keyboard, / is Shift + 7).

@mcornella
Copy link
Member

Hi @danielfernandez, please post the following:

  • Output of setopt
  • Output of bindkey '^I'

That said, you may first want to try if setopt autoparamslash (see documentation) fixes it for you. Though if this only happens for .. I don't think that'll be the problem.

@danielfernandez
Copy link
Author

Sure:

➜  ~  setopt
alwaystoend
autocd
autopushd
cdablevars
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactive
login
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
➜  ~  bindkey '^I'
"^I" expand-or-complete

@mcornella
Copy link
Member

Hi @danielfernandez, sorry for the long delay. That setopt autoparamslash option should have done the trick. Can you add it to your zshrc file and check again? If it doesn't work, please post the contents of your zshrc file.

@danielfernandez
Copy link
Author

Actually, the setopt autoparamslash command seems to do nothing :( Just after I execute it, a setopt does not show autoparamslash as set...
See:

➜  ~  setopt autoparamslash
➜  ~  setopt
alwaystoend
autocd
autopushd
cdablevars
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
incappendhistory
interactive
interactivecomments
login
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle

And these are the contents of my .zshrc.

# Path to your oh-my-zsh installation.
export ZSH=/Users/daniel/.oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)

# User configuration

export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# export MANPATH="/usr/local/man:$MANPATH"

source $ZSH/oh-my-zsh.sh

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# setting this explicitly in order to autocomplete '..' -> '../'
setopt autoparamslash

By the way, I'm using iTerm2 build 2.1.1 on OS X Yosemite 10.10.3

@apjanke
Copy link
Contributor

apjanke commented Jul 28, 2015

Same as #4177; more discussion there.

I think this is normal zsh behavior: .. is not considered an exact match for files.. When hitting <tab> after .., it won't insert a slash, regardless of whether OMZ is loaded. (Is it inserting a slash for you, @mcornella?)

I wasn't able to find any zsh option that would enable this. This might be a question for the zsh-users mailing list.

Might be able to hack this to work in OMZ by hacking the _cd completion function or supplying a file completion widget that considered .. a full match in certain cases. This would probably be tricky, so may be better suited for a plugin than core OMZ code.

@mcornella
Copy link
Member

Found it! I had this behavior because I had a line in my zshrc file that wasn't in the template one:

zstyle ':completion:*' special-dirs true

That will enable completion of special dirs (. and ..). I think I got it some time ago from stackoverflow.

You can close this issue

@danielfernandez
Copy link
Author

Awesome! that did the trick :-)

Gràcies @mcornella! Closing this…

@mcornella
Copy link
Member

😉

@apjanke
Copy link
Contributor

apjanke commented Jul 28, 2015

Nice find!

@kristoiv
Copy link

Awesome! Thanks :) 👍

@wsdjeg
Copy link

wsdjeg commented Sep 13, 2015

maybe you can try ../(tab!)

@Kaito23
Copy link

Kaito23 commented Mar 22, 2017

hey,
for me the fix is only temporary. If I open a new tab in iterm2
i need to reinput the line.
I hotfixed it with adding this line to the settings in my profile ("send text at start")
is there another way to fix this?

@zgcasas
Copy link

zgcasas commented Jun 29, 2017

  • Edit ~/.zshrc
  • Add it to end of the file zstyle ':completion:*' special-dirs true
  • Save
  • Open a new terminal

@mcornella
Copy link
Member

Just as a heads up, this setting is now enabled by default.

mcornella added a commit that referenced this issue May 7, 2018
aunsira pushed a commit to aunsira/oh-my-zsh that referenced this issue Jun 13, 2018
gsemet pushed a commit to gsemet/oh-my-zsh that referenced this issue Jun 15, 2018
seth-cohen pushed a commit to seth-cohen/oh-my-zsh that referenced this issue Oct 29, 2018
jmartindf pushed a commit to jmartindf/oh-my-zsh that referenced this issue Nov 10, 2018
sagischwarz pushed a commit to sagischwarz/ohmyzsh that referenced this issue Nov 19, 2018
chihchun pushed a commit to chihchun/oh-my-zsh that referenced this issue Aug 6, 2019
kankongmeng pushed a commit to kankongmeng/oh-my-zsh that referenced this issue Jan 8, 2020
spiliopoulos pushed a commit to spiliopoulos/zsh-config that referenced this issue Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants