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/bin/tmux-session-list

32 lines
897 B
Plaintext
Raw Normal View History

2017-04-23 06:47:00 -05:00
#!/usr/bin/env bash
2018-04-07 14:16:18 -05:00
ANY_SESSION_PREFIX="#[bg=colour18]#[fg=colour7]"
ANY_SESSION_SUFFIX="#[bg=default]#[fg=default] "
2020-04-20 10:38:19 -05:00
CUR_SESSION_PREFIX="#[bg=colour4]#[fg=colour0]"
2018-04-07 14:16:18 -05:00
CUR_SESSION_SUFFIX="${ANY_SESSION_SUFFIX}"
2020-04-20 10:38:19 -05:00
# TODO: implement urgent session highlighting
# URG_SESSION_SUFFIX="${ANY_SESSION_SUFFIX}"
# URG_SESSION_PREFIX="#[bg=colour1]#[fg=colour0]"
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
2018-04-07 14:16:18 -05:00
TMUX_SESSION_LIST="$(tmux list-sessions | awk \
-v curSesh="${CUR_TMUX_SESSION}" \
2018-04-07 14:16:18 -05:00
-v aspre="${ANY_SESSION_PREFIX}" \
-v assuf="${ANY_SESSION_SUFFIX}" \
-v cspre="${CUR_SESSION_PREFIX}" \
-v cssuf="${CUR_SESSION_SUFFIX}" \
'{s=substr($1,0,length($1)-1);
if(s==curSesh){
2018-04-07 14:16:18 -05:00
s=cspre" "s" "cssuf
}else{
s=aspre" "s" "assuf
}printf s}')"
2017-04-23 06:47:00 -05:00
2020-04-20 10:38:19 -05:00
# shellcheck disable=SC2001
echo "${TMUX_SESSION_LIST//\s*$/}" | sed -e 's/\s*$//'