Skip to content

Instantly share code, notes, and snippets.

@bfatemi
Created July 15, 2019 21:12
Show Gist options
  • Save bfatemi/e0497052c027678485098d727aa16f2a to your computer and use it in GitHub Desktop.
Save bfatemi/e0497052c027678485098d727aa16f2a to your computer and use it in GitHub Desktop.
# Change directory to the current Finder directory
cdf() {
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 [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
# Syntax highlighting in cat
cat() {
local out colored
out=$(/bin/cat $@)
colored=$(echo $out | pygmentize -f console -g 2>/dev/null)
[[ -n $colored ]] && echo "$colored" || echo "$out"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment