#!/usr/bin/env bash
ANY_SESSION_PREFIX="#[bg=colour18]#[fg=colour7]"
CUR_SESSION_PREFIX="#[bg=colour4]#[fg=colour0]"
ANY_SESSION_SUFFIX="#[bg=default]#[fg=default] "
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}"