Last active
November 30, 2021 18:07
-
-
Save tateren/269342556e877d591f777d8679a7c2c7 to your computer and use it in GitHub Desktop.
Auto start abduco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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