Hi, just wanted to share a very simple but helpful function. It returns the
parent folder of the given argument/pipe.
function folder
if ! isatty stdin
cat - | read -at argv
end
for file in $argv
echo (path resolve $file | path dirname | string split '/')[-1]
end
end
Note that you might want to remove the `resolve` part depending on your use
case. For me it is more useful like this since I use it to rename files and I
never need to name anything `.` .
I think `path` is one of the best things about Fish; it makes this kind of
operation very easy. Even so, there was no convenient way that I could find to
get only the containing folder, not the entire path. Now there is! :)
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users