-
-
Save pschyska/884c9a8507c3f729eb0b6a58bf2ce1cf to your computer and use it in GitHub Desktop.
resolve executable in PATH to nix store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ q bash | |
# /nix/store/8wbyyhschvbg0r3p6lh6vpvys6zk4ivc-bash-interactive-4.4-p23/bin/bash | |
q() { | |
readlink -e "$(type -a -p "$@")" | |
} | |
# $ qr bash | |
# /nix/store/8wbyyhschvbg0r3p6lh6vpvys6zk4ivc-bash-interactive-4.4-p23 | |
qr() { | |
recurse() { | |
local slashes="${1//[^\/]}" | |
if [[ "$1" =~ /^\/nix\/store ]] && [ ${#slashes} -gt 3 ]; then | |
recurse "$(dirname "$1")" | |
else | |
printf "%s\n" "$1" | |
fi | |
} | |
recurse "$(readlink -e "$(type -a -p "$1")")" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment