Created
February 9, 2024 09:17
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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