blob: dada65e236a6634d8b6141df55e814e8ba5ab60a (
plain) (
blame)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/bin/sh
# Path to your projects directory
Prefix="$HOME/proj"
# Paths in which to search for projects
Paths="
$Prefix
$Prefix/handmade
$Prefix/suckless
$Prefix/personal
$Prefix/thirdparty
$Prefix/school
"
if [ $# -eq 1 ]; then
Selected="$1"
else
# Exclude the search paths themselves
Args="$(
for Path in $Paths
do
printf -- "%s\n" "-a ( -not -path "$Path" ) "
done
)"
Selected="$(find $Paths -mindepth 1 -maxdepth 1 -type d $Args | sed "s@$Prefix/@@" | fzf)"
{ [ "$Selected" ] && [ -d "$Prefix/$Selected" ]; } || exit 1
fi
if [ -z "$Selected" ]; then
exit 0
fi
TmuxRunning="$(pgrep "tmux" | head -n1)"
Session="${Selected##*/}"
if [ -z $TMUX ] && [ -z "$TmuxRunning" ]; then
tmux new-session -s "$Session" -c "$Prefix"/"$Selected"
herbe 1
else
if ! tmux has-session -t="$Session" 2> /dev/null; then
tmux new-session -ds "$Session" -c "$Prefix"/"$Selected"
fi
if [ -z $TMUX ]; then
tmux attach -t "$Session"
else
tmux switch-client -t "$Session"
fi
fi
|