Skip to content

Instantly share code, notes, and snippets.

@tateren tateren/abduco.zsh
Last active Jun 19, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.