From 02a44619f379e4797ecbaf198ca6250c93708555 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 31 Aug 2021 10:42:56 +0100 Subject: [PATCH] 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 --- shells/zsh/includes/keybindings.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shells/zsh/includes/keybindings.zsh b/shells/zsh/includes/keybindings.zsh index 82612de6..e1d1d123 100644 --- a/shells/zsh/includes/keybindings.zsh +++ b/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