Compare commits

..

No commits in common. "d647d36f10cacb5c6ef1b72ef891ecef5699e24a" and "0ede957833edc1735c6df15b6fbc5728ef28c7f4" have entirely different histories.

View File

@ -5,14 +5,6 @@ set -o emacs
bind '"\e": "\C-W\c-d"'
OPEN_MODE="new_pane"
CACHE_FILE=~/.cache/project_list
# Close tmux popup if any and quit
exit_script () {
tmux display-popup -C
exit $1
}
debug () {
if [ "$VERBOSE" = true ]; then
@ -24,7 +16,7 @@ spinner() {
local s="⣾⣽⣻⢿⡿⣟⣯⣷"
local -i i=0
while :; do
printf "%s\\r" "${s:$((i++%8)):1}" >&2
printf "%s\\r" "${s:$((i++%4)):1}" >&2
sleep .1
done
@ -35,7 +27,8 @@ open_local () {
tmux send-keys C-c
tmux send-keys "cd $PROJECT_PATH" Enter
exit_script 0
# Close tmux popup if any
tmux display-popup -C
}
open_new_pane () {
@ -53,13 +46,8 @@ open_new_pane () {
tmux switch-client -t $SESSION_NAME:$PROJECT_NAME
exit_script 0
}
update_project_list_cache() {
PROJECT_LIST_UPDATE=$(find ~/* -name .git -type d -not -path "~/.*" -prune 2>/dev/null | sed 's/\/.git/\n/g' | sed "s/$(echo $HOME | sed 's/\//\\\//g')//" | cut -d'/' -f2-)
echo $PROJECT_LIST_UPDATE > $CACHE_FILE
# Close tmux popup if any
tmux display-popup -C
}
while getopts "lv" option; do
@ -80,28 +68,15 @@ CUSTOM_SESSIONS[Projects]=Halia
spinner &
spinner_pid=$!
if [ ! -f "$CACHE_FILE" ]; then
debug "Start synchronous project list cache update"
update_project_list_cache
else
debug "Start asynchronous project list cache update"
update_project_list_cache &
fi
PROJECT_LIST=$(cat $CACHE_FILE)
PROJECT_LIST=$(find ~/* -name .git -type d -not -path "~/.*" -prune 2>/dev/null)
kill $spinner_pid
SELECTED=$(echo $PROJECT_LIST | tr ' ' '\n' | fzf)
SELECTED=$(echo $PROJECT_LIST | sed 's/\/.git/\n/g' | sed "s/$(echo $HOME | sed 's/\//\\\//g')//" | cut -d'/' -f2- | fzf)
debug "Selected $SELECTED"
# Quit if nothing has been selected
if [ ! $SELECTED ]; then
exit_script 1
fi
PROJECT_PATH=$(realpath ~/${SELECTED})
PROJECT_PATH=$(echo $PROJECT_LIST | sed 's/\/.git/\n/g' | grep "${SELECTED}$")
PROJECT_ROOT=$(echo $SELECTED | cut -d '/' -f1)
PROJECT_NAME=$(echo $SELECTED | rev | cut -d '/' -f1 | rev)