3 ms·
I have something that serves a similar purpose - a shell script that calls out to AppleScript to get the path of the most recently used Finder window and return
by Ancapistani 4y ago
I have something that serves a similar purpose - a shell script that calls out to AppleScript to get the path of the most recently used Finder window and returns it as a string:
#!/usr/bin/env bash
####################
# Description: Get the path of the most recently used Finder window
# Author: Ancapistani
# Version: 1.0.0
####################
osascript -e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "get POSIX path of (target of window ${1-1} as alias)"\
-e 'else' \
-e 'get POSIX path of (desktop as alias)'\
-e 'end if' \
-e 'end tell';
I have this saved as `fpwd` in my shell.
- cute_boi 4y agothe problem with such approach is it leaves terminal item in dock. I use warp terminal and it is really annoying.