Recently I’ve stumbled upon a branch of fish shell tweaked to work well on OS X. It was really great but I was missing some neat commands I had in my zsh. I tried to replicate them but failed at first mostly because fish does IO redirection in a different way.
After half an hour of googling and another half an hour of pulling my hairs while trying to fix a lot of strange errors I succeeded! And here goes the result. To use it put these files into ~/.config/fish/functions/ folder. Create it if it doesn’t exist.
pfdir.fish will print folder path of the topmost Finder’s window
pfsel.fish will print the paths to all selected files and folders of the topmost Finder’s window
Have to say I couldn’t do it without already existing and great oh-my-zsh plugin: https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/osx/osx.plugin.zsh
It’s definitely worth checking out if you prefer zsh.