zsh: add deref function to turn a symlink into a real file

This commit is contained in:
Colin 2024-03-08 08:50:28 +00:00
parent c0a94995a5
commit 39411164af

View File

@ -162,10 +162,19 @@ in
# extra aliases # extra aliases
# TODO: move to `shellAliases` config? # TODO: move to `shellAliases` config?
function c() { function c() {
# list a dir after entering it
cd "$1" cd "$1"
eza --oneline eza --oneline
} }
function deref() {
# convert a symlink into a plain file of the same content
if [ -L "$1" && -f "$1" ]; then
cp --dereference "$1" "$1.deref"
mv -f "$1.deref" "$1"
fi
}
function nd() { function nd() {
# enter a directory, creating it if necessary
mkdir -p "$1" mkdir -p "$1"
pushd "$1" pushd "$1"
} }