profiles/dev: improve custom functions

This commit is contained in:
Gabriel Arazas 2022-07-08 06:27:12 +08:00
parent 3250b21acd
commit ff18237d0b

View File

@ -47,21 +47,21 @@ in {
dir=''${1:-$PWD} dir=''${1:-$PWD}
dest=$(${pkgs.fd}/bin/fd --type directory --hidden --ignore-vcs --base-directory "$dir" \ dest=$(${pkgs.fd}/bin/fd --type directory --hidden --ignore-vcs --base-directory "$dir" \
| ${pkgs.fzf}/bin/fzf --prompt "Go to directory ") | ${pkgs.fzf}/bin/fzf --prompt "Go to directory ")
destPrime=$(${pkgs.coreutils}/bin/realpath --canonicalize-existing --logical "$dir/$dest") destPrime=$(${pkgs.coreutils}/bin/realpath --canonicalize-existing --logical "$dest")
cd "$destPrime" [ "$dest" ] && cd "$destPrime"
} }
function ff() { function ff() {
dir=''${1:-$PWD} dir=''${1:-$PWD}
dest=$(${pkgs.fd}/bin/fd --hidden --ignore-vcs --base-directory "$dir" \ dest=$(${pkgs.fd}/bin/fd --hidden --ignore-vcs --base-directory "$dir" \
| ${pkgs.fzf}/bin/fzf --prompt "Open file ") | ${pkgs.fzf}/bin/fzf --prompt "Open file ")
destPrime=$(${pkgs.coreutils}/bin/realpath --canonicalize-existing --logical "$dir/$dest") destPrime=$(${pkgs.coreutils}/bin/realpath --canonicalize-existing --logical "$dest")
if [ -d "$destPrime" ]; then if [ -d "$destPrime" ]; then
cd "$destPrime"; [ "$dest" ] && cd "$destPrime";
else else
${pkgs.xdg-utils}/bin/xdg-open "$destPrime"; [ "$dest" ] && ${pkgs.xdg-utils}/bin/xdg-open "$destPrime";
fi fi
} }