summary refs log tree commit diff stats
path: root/user/zsh/zshrc
diff options
context:
space:
mode:
Diffstat (limited to 'user/zsh/zshrc')
-rw-r--r--user/zsh/zshrc20
1 files changed, 20 insertions, 0 deletions
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