diff options
author | Alan Pearce | 2023-04-25 21:43:02 +0200 |
---|---|---|
committer | Alan Pearce | 2023-04-25 21:43:02 +0200 |
commit | 9389e4954b12c12b2f020236bd6642f238ec8c9b (patch) | |
tree | be5ad8427118ec518b3c98cf70ccbc07b8d17989 /user/zsh/zshrc | |
parent | cb9dbecb7080f5989e5bcc07959c719ee05cea81 (diff) | |
download | nixfiles-9389e4954b12c12b2f020236bd6642f238ec8c9b.tar.lz nixfiles-9389e4954b12c12b2f020236bd6642f238ec8c9b.tar.zst nixfiles-9389e4954b12c12b2f020236bd6642f238ec8c9b.zip |
zsh: add function to move a file and replace it with a link
Diffstat (limited to 'user/zsh/zshrc')
-rw-r--r-- | user/zsh/zshrc | 20 |
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 |