all repos — nixfiles @ ee51c126d95515cc6bc4c5109a225ccf559dc516

System and user configuration, managed by nix and home-manager

zsh: add `delink` function to replace a symlink with a copy

Alan Pearce
commit

ee51c126d95515cc6bc4c5109a225ccf559dc516

parent

987d8c5d2a25ece7ee2f06046cb0480047ddef08

1 file changed, 12 insertions(+), 0 deletions(-)

jump to
M user/zsh/zshrcuser/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