Skip to content

Instantly share code, notes, and snippets.

@tateren
Last active November 30, 2021 18:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tateren/269342556e877d591f777d8679a7c2c7 to your computer and use it in GitHub Desktop.
Save tateren/269342556e877d591f777d8679a7c2c7 to your computer and use it in GitHub Desktop.
Auto start abduco
# Requirement
# - [fzf](https://github.com/junegunn/fzf)
#
if [ "$ABDUCO_SESSION_NAME" = "" ]; then
export ABDUCO_SESSION_NAME="session_$(date +%s)"
SESSIONS="$(abduco | tail -n +2)"
if [ -z "$SESSIONS" ]; then
abduco -c "$ABDUCO_SESSION_NAME" "$SHELL" && exit
fi
NEW_SESSION="[Create new session]"
SESSION="$(echo "${SESSIONS}\n${NEW_SESSION}" | fzf --reverse)"
if [ "$SESSION" = "$NEW_SESSION" ]; then
abduco -c "$ABDUCO_SESSION_NAME" "$SHELL" && exit
elif [ -n "$SESSION" ]; then
export ABDUCO_SESSION_NAME="$(echo "$SESSION" | awk '{print $NF}')"
abduco -a "$ABDUCO_SESSION_NAME" && exit
else
: # start without abduco
fi
fi
abduco() {
ABDUCO='/path/to/abduco'
if [ "$#" -eq 0 ]; then
# highlight current session
${ABDUCO} | grep --color=auto -E ".*${ABDUCO_SESSION_NAME:-' '}$|$"
else
${ABDUCO} "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment