2023-02-18 17:52:24 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
GIT_DIRS=("$HOME/work" "$HOME/projects" "$HOME/git" "$HOME/WebStormProjects" "$HOME/RiderProjects")
|
|
|
|
|
|
|
|
function open_app() {
|
|
|
|
application="$1"
|
|
|
|
project="$2"
|
|
|
|
|
|
|
|
exe=$(grep "Exec" "$HOME/.local/share/applications/jetbrains-$application.desktop" | sed 's/.*"\([^"]*\)".*/\1/')
|
|
|
|
$exe "$project" &> /dev/null &
|
|
|
|
}
|
|
|
|
|
2023-02-18 18:10:10 -05:00
|
|
|
function get_icon {
|
|
|
|
application=$1
|
|
|
|
grep "Icon" "$HOME/.local/share/applications/jetbrains-$application.desktop" | sed 's/Icon=//'
|
|
|
|
}
|
|
|
|
|
2023-02-18 17:52:24 -05:00
|
|
|
function file_exists() {
|
|
|
|
project="$1"
|
|
|
|
file="$2"
|
|
|
|
files=($project/$file)
|
|
|
|
if [ -e "${files[0]}" ]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-02-18 18:10:10 -05:00
|
|
|
function get_project_type() {
|
2023-02-18 17:52:24 -05:00
|
|
|
project="$1"
|
|
|
|
|
|
|
|
if file_exists "$project" "pom.xml"; then
|
2023-02-18 18:10:10 -05:00
|
|
|
echo "idea"
|
2023-02-18 17:52:24 -05:00
|
|
|
elif file_exists "$project" "package.json"; then
|
2023-02-18 18:10:10 -05:00
|
|
|
echo "webstorm"
|
2023-02-18 17:52:24 -05:00
|
|
|
elif file_exists "$project" "cargo.toml" || file_exists "$project" "*.c"; then
|
2023-02-18 18:10:10 -05:00
|
|
|
echo "clion"
|
2023-02-18 17:52:24 -05:00
|
|
|
elif file_exists "$project" "*.csproj"; then
|
2023-02-18 18:10:10 -05:00
|
|
|
echo "rider"
|
2023-02-18 17:52:24 -05:00
|
|
|
elif file_exists "$project" "*.py"; then
|
2023-02-18 18:10:10 -05:00
|
|
|
echo "pycharm"
|
2023-02-18 17:52:24 -05:00
|
|
|
elif file_exists "$project" "*.go"; then
|
2023-02-18 18:10:10 -05:00
|
|
|
echo "goland"
|
2023-02-18 17:52:24 -05:00
|
|
|
else
|
2023-02-18 18:10:10 -05:00
|
|
|
echo "idea"
|
2023-02-18 17:52:24 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$1" == "" ]]; then
|
|
|
|
for dir in $(echo ${GIT_DIRS[*]}); do
|
|
|
|
if [ -e "$dir" ]; then
|
2023-02-18 18:10:10 -05:00
|
|
|
projects=$(find $dir -maxdepth 1 -mindepth 1 -type d)
|
|
|
|
for project in $projects; do
|
|
|
|
echo -en "$project\0icon\x1f$(get_icon "$(get_project_type "$project")")\n"
|
|
|
|
done
|
2023-02-18 17:52:24 -05:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
2023-02-18 18:10:10 -05:00
|
|
|
open_app "$(get_project_type "$1")" "$1"
|
2023-02-18 17:52:24 -05:00
|
|
|
fi
|