ZSH: fixes issue for creaing directory with ~ in path

The alt-m key binding is used to create a directory for the current
"word". This change makes it work if it has something like ~ in the
name.

${~var} is used to turn on GLOB_SUBST. The string resulting from the
expansion will be interpreted as a pattern anywhere that is possible,
such as filenames expanding `~`

man zshexpn
Jonathan Hodgson 3 years ago
parent f030d0da98
commit 02a44619f3
  1. 6
      shells/zsh/includes/keybindings.zsh

@ -100,11 +100,11 @@ make_current_word_directory(){
else else
folder="${folder//\\ / }" folder="${folder//\\ / }"
fi fi
folder="${folder%/*}" folder="${~folder%/*}"
if [ -e "$folder" ]; then if [ -e "${~folder}" ]; then
zle -M "$folder already exists" zle -M "$folder already exists"
else else
output="$(mkdir -p "$folder" 2>&1)" output="$(mkdir -p "${~folder}" 2>&1)"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
zle -M "$folder created" zle -M "$folder created"
else else

Loading…
Cancel
Save