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
This commit is contained in:
Jonathan Hodgson 2021-08-31 10:42:56 +01:00
parent b086532297
commit afb31a7589

View file

@ -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