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

30 lines
703 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]"
CUR_SESSION_PREFIX="#[bg=colour4]#[fg=colour0]"
2018-04-07 14:16:18 -05:00
ANY_SESSION_SUFFIX="#[bg=default]#[fg=default] "
CUR_SESSION_SUFFIX="${ANY_SESSION_SUFFIX}"
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}" \
-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
}')"
2017-04-23 06:47:00 -05:00
2018-04-07 14:16:18 -05:00
echo "${TMUX_SESSION_LIST}"