From 1079df752f29d1af0501c1b6fdd36cb477189c0c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 22 Aug 2020 15:09:09 -0300 Subject: Feat: support for selecting only some programs in a session --- session | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/session b/session index 3cca7a2..fdb4750 100755 --- a/session +++ b/session @@ -25,6 +25,14 @@ function __session_not_ignored { return 1 fi + if [ ! -z "$UNIGNORE" ]; then + if [ "$UNIGNORE" == "$1" ]; then + return 0 + else + return 1 + fi + fi + return 0 } @@ -143,11 +151,14 @@ function __session_chooser { __session_list read -rep "Choose session: " n - if [ ! -z "$n" ]; then - session="$(__session_list | grep -E "(^$n.| $n:)" | sed -e "s/^[0-9]*. //" | cut -d : -f 1)" + local name="`echo $n | awk '{ print $1 }'`" + local program="`echo $n | awk '{ print $2 }'`" + + if [ ! -z "$name" ]; then + session="$(__session_list | grep -E "(^$name.| $name:)" | sed -e "s/^[0-9]*. //" | cut -d : -f 1)" if [ ! -z "$session" ]; then - __session_open $session + __session_open $session $program fi fi } @@ -169,6 +180,11 @@ function __session_exec { # Open a session function __session_open { local session="$1" + local program="$2" + + if [ ! -z "$program" ]; then + UNIGNORE="$program" + fi # Custom if __session_not_ignored custom && [ -e "$CUSTOM/$session" ]; then @@ -239,7 +255,7 @@ elif [ ! -z "$1" ] && echo "$1" | grep -q -- '--list'; then elif [ ! -z "$1" ] && echo "$1" | grep -q -- '--chooser'; then __session_chooser elif [ -z "$1" ]; then - echo "usage: $BASENAME [--list|--chooser] " + echo "usage: $BASENAME [--list|--chooser] " echo "available sessions:" echo "" __session_list -- cgit v1.2.3