From ff18237d0b125b5e17439c10e87c9ee8fcb497b4 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Fri, 8 Jul 2022 06:27:12 +0800 Subject: [PATCH] profiles/dev: improve custom functions --- modules/home-manager/profiles/dev.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/home-manager/profiles/dev.nix b/modules/home-manager/profiles/dev.nix index b69a9c8c..699f92ab 100644 --- a/modules/home-manager/profiles/dev.nix +++ b/modules/home-manager/profiles/dev.nix @@ -47,21 +47,21 @@ in { dir=''${1:-$PWD} dest=$(${pkgs.fd}/bin/fd --type directory --hidden --ignore-vcs --base-directory "$dir" \ | ${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() { dir=''${1:-$PWD} dest=$(${pkgs.fd}/bin/fd --hidden --ignore-vcs --base-directory "$dir" \ | ${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 - cd "$destPrime"; + [ "$dest" ] && cd "$destPrime"; else - ${pkgs.xdg-utils}/bin/xdg-open "$destPrime"; + [ "$dest" ] && ${pkgs.xdg-utils}/bin/xdg-open "$destPrime"; fi }