Hacker News new | ask | show | jobs
by superfamicom 1402 days ago
On macOS this can be really useful, change the current terminal to the top most folder in Finder, do not recall where it came from:

  # Change to the Front Folder open in Finder
  function ff {
    osascript -e 'tell application "Finder"'\
    -e 'if (0 < (count Finder windows)) then'\
    -e 'set finderpath to get target of the front window as alias'\
    -e 'else'\
    -e 'set finderpath to get desktop as alias'\
    -e 'end if'\
    -e 'get POSIX path of finderpath'\
    -e 'end tell';};\
  function cdff { cd "`ff $@`" || exit; };