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
master
Jonathan Hodgson 3 years ago
parent b086532297
commit afb31a7589
  1. 6
      shells/zsh/includes/keybindings.zsh

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

Loading…
Cancel
Save