#!/usr/bin/env bash
ANY_SESSION_PREFIX="#[bg=colour18]#[fg=colour7]"
CUR_SESSION_PREFIX="#[bg=colour4]#[fg=colour0]"
URG_SESSION_PREFIX="#[bg=colour1]#[fg=colour0]"
ANY_SESSION_SUFFIX="#[bg=default]#[fg=default] "
URG_SESSION_SUFFIX="${ANY_SESSION_SUFFIX}"
CUR_SESSION_SUFFIX="${ANY_SESSION_SUFFIX}"
CUR_TMUX_SESSION="$1"
if [ -z "$1" ]; then
CUR_TMUX_SESSION="$(tmux display-message -p '#S')"
fi
export CUR_TMUX_SESSION
TMUX_SESSION_LIST="$(tmux list-sessions | awk \
-v curSesh="${CUR_TMUX_SESSION}" \
-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){
s=cspre" "s" "cssuf
}else{
s=aspre" "s" "assuf
}printf s}')"
echo "${TMUX_SESSION_LIST//\s*$/}" | sed -e 's/\s*$//'