zsh: add function to move a file and replace it with a link
Alan Pearce alan@alanpearce.eu
Tue, 25 Apr 2023 21:43:02 +0200
1 files changed, 20 insertions(+), 0 deletions(-)
jump to
M user/zsh/zshrc → user/zsh/zshrc
@@ -38,6 +38,26 @@ cp "$src" "$1" chmod u+w "$1" } +mvlink () { + src="$1" + target="$2" + if [[ -h "$src" ]] + then + echo "$src is already a symlink" + return src + fi + if [[ -f "$target" ]] + then + echo "$target already exists" + fi + if [[ -d "$target" ]] + then + target="$target/$(basename $src)" + fi + mv "$src" "$target" + ln -s "$target" "$src" +} + backward-argument () { local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" zle backward-word