-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhich.fish
More file actions
31 lines (27 loc) · 818 Bytes
/
which.fish
File metadata and controls
31 lines (27 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function which --description "which, but with more info"
set -l count (count $argv)
for arg in $argv
set -l path (command which $arg)
if test $status -ne 0
if test $count -gt 1
echo -n "$arg: " >&2
end
echo "not found" >&2
return 1
end
if test $count -gt 1
echo -n "$arg: "
end
echo "$path"
while test -L "$path"
# Get the target of the link
set -l target (readlink "$path")
# Resolve the link target relative to the directory of the link
pushd (dirname "$path") 2>/dev/null
set path (realpath --no-symlinks "$target")
popd 2>/dev/null
echo " -> $path"
end
end
return 0
end