This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/scripts/bin/tmux-session-list

23 lines
937 B
Plaintext
Raw Normal View History

2017-04-23 06:47:00 -05:00
#!/usr/bin/env bash
CUR_SESSION_PREFIX="#[bg=colour4]#[fg=colour0]"
CUR_SESSION_SUFFIX="#[bg=default]#[fg=default]"
2017-04-23 06:47:00 -05:00
CUR_TMUX_SESSION="$1"
2017-04-23 06:47:00 -05:00
if [ -z "$1" ]; then
CUR_TMUX_SESSION="$(tmux display-message -p '#S')"
2017-04-23 06:47:00 -05:00
fi
export CUR_TMUX_SESSION
2017-04-23 06:47:00 -05:00
TMUX_SESSION_LIST="$(tmux list-sessions | sed -ne 's/^\([^:]*\).*$/ \1 /p' | tr -d '\n')"
2017-04-23 06:47:00 -05:00
HIGHLIGHT_CUR_SESSION="${TMUX_SESSION_LIST/ $CUR_TMUX_SESSION /${CUR_SESSION_PREFIX} ${CUR_TMUX_SESSION} ${CUR_SESSION_SUFFIX}}"
# ADD_END_SPACE_IF_NECESSARY=$(echo "$HIGHLIGHT_CUR_SESSION" | sed -e 's/\([^]]\)$/\ /p')
# REMOVE_START_SPACE_IF_NECESSARY=$(echo "$HIGHLIGHT_CUR_SESSION" | sed 's/^ #/#/')
REMOVE_START_SPACE_IF_NECESSARY=${HIGHLIGHT_CUR_SESSION/^ \#/\#/}
2017-04-23 06:47:00 -05:00
# echo "cursess: $CUR_TMUX_SESSION -- sesslist: $TMUX_SESSION_LIST -- withhili: $HIGHLIGHT_CUR_SESSION -- cutspace: $REMOVE_START_SPACE_IF_NECESSARY -- argv1: $1 -- TMUX: $TMUX" >> ~/.tmux.log
2017-04-23 06:47:00 -05:00
echo "$REMOVE_START_SPACE_IF_NECESSARY"