From 9389e4954b12c12b2f020236bd6642f238ec8c9b Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 25 Apr 2023 21:43:02 +0200 Subject: zsh: add function to move a file and replace it with a link --- user/zsh/zshrc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/user/zsh/zshrc b/user/zsh/zshrc index 6a60a060..831ada1e 100644 --- a/user/zsh/zshrc +++ b/user/zsh/zshrc @@ -38,6 +38,26 @@ delink () { 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 -- cgit 1.4.1