-
Notifications
You must be signed in to change notification settings - Fork 1
/
project-opener
executable file
·40 lines (32 loc) · 995 Bytes
/
project-opener
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# production: false
PROJECT_PATH="$HOME/documents/"
# The 'projects' are directories with git repos
paths=$(find $PROJECT_PATH -name '.git' -print |
grep -v 'Permission denied' |
xargs -n 1 dirname
)
projects=$(echo "$paths" | awk -F '/' '{ print $NF }')
# Also get docker containers running
containers=$(docker ps --format "{{.Names}}")
# Format options for rofi
containers_fmt=$(echo -e "$containers" | nl)
next_index=$(echo "$containers_fmt" | awk 'END { print $1+1 }')
projects_fmt=$(echo -e "$projects" | nl -v $next_index)
# Format rofi options
if [[ $containers != "" ]]; then
options="Containers:
$containers_fmt
Projects
$projects_fmt"
else
options="Projects
$projects_fmt"
fi
vscode_paths=($containers $projects)
# Collect input
choice=$(echo -e "$options" | rofi -dmenu -show | awk '{ print $1 }')
echo $choice
echo -e "${vscode_paths[(($choice-1))]}"
# # Execute VSCode with the project path
# [ "$choice" != "" ] && code ${path_dict[$choice]}