Skip to content

Instantly share code, notes, and snippets.

@zackijack
Created February 9, 2024 09:17
Show Gist options
  • Save zackijack/eab20fb8640efec5acc50f0cbbd16900 to your computer and use it in GitHub Desktop.
Save zackijack/eab20fb8640efec5acc50f0cbbd16900 to your computer and use it in GitHub Desktop.
The 'e' function opens files or directories in the appropriate IDE based on their type.
# Opens files or directories in the appropriate IDE based on their type.
e() {
ITEM="${1:-.}"
if [ -d "$ITEM" ]; then
if [ $(find "$ITEM" -name "*.go" | wc -l) -gt 0 ]; then
goland "$ITEM"
elif [ $(find "$ITEM" -name "*.php" | wc -l) -gt 0 ]; then
phpstorm "$ITEM"
elif [ $(find "$ITEM" -name "*.js" | wc -l) -gt 0 ]; then
webstorm "$ITEM"
else
code "$ITEM"
fi
elif [ -f "$ITEM" ]; then
case "$ITEM" in
*.go) goland "${ITEM%.*}";;
*.php) phpstorm "${ITEM%.*}";;
*.js) webstorm "${ITEM%.*}";;
*) code "$ITEM";;
esac
else
echo "$ITEM is not a valid directory or file"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment