Skip to content

Instantly share code, notes, and snippets.

@zelaznik
Created June 17, 2022 16:55
Show Gist options
  • Save zelaznik/899f91990001b7bc9cb8853cfc0d180d to your computer and use it in GitHub Desktop.
Save zelaznik/899f91990001b7bc9cb8853cfc0d180d to your computer and use it in GitHub Desktop.
#!/bin/bash
function find_existing_files() {
# This prevents me from shooting myself in the foot when I'm
# grepping for a pattern and forget to include "-l" before
# using xargs to open the files in sublime
for filepath in $@; do
if [ -f $filepath ]; then
echo $filepath
fi
if [ -d $filepath ]; then
echo $filepath
fi
done
}
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl $(find_existing_files $@)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment