function cdf --description="If on OSX, `cd` to the directory the front Finder window is open to."
	set --local target (osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)')
	if test -n target
		echo "Changing directory to: $target"
		cd $target
	else
		echo "No Finder window found." >&2
		return 1
	end
end


function cdf --description="If on OSX, `cd` to the directory the front Finder window is open to."
	# first we check if we're on OSX
	if not test (uname -s) = "Darwin"
		echo "We are not on OSX." >&2
		return 3
	end
	set --local target (osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)')
	if test -n target
		echo "Changing directory to: $target"
		cd $target
	else
		echo "No Finder window found." >&2
		return 1
	end
end


Add a check for operating system.
Add a check for operating system.

As this function is being added to my dotfiles repository, a check was
added to avoid awkward errors if unintentionally used on another system.

deoxys314/deoxys314_dotfiles