zsh: add `delink` function to replace a symlink with a copy
Alan Pearce alan@alanpearce.eu
Wed, 12 Apr 2023 11:59:38 +0200
1 files changed, 12 insertions(+), 0 deletions(-)
jump to
M user/zsh/zshrc → user/zsh/zshrc
@@ -26,6 +26,18 @@ awk "{ print \$${1:-0} }" } alias f=field +delink () { + if [[ ! -h "$1" ]] + then + echo "$1 is not a symlink" + return 1 + fi + local src=$(readlink "$1") + rm "$1" + cp "$src" "$1" + chmod u+w "$1" +} + backward-argument () { local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\"" zle backward-word