diff options
| author | Shulhan <ms@kilabit.info> | 2025-04-05 16:46:48 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-04-09 22:25:56 +0700 |
| commit | ce18a33847d49a867c7f63d364f252aecb8831aa (patch) | |
| tree | c10ca24ca0cd7a86a8dc1be05b56fd99fcdff1d2 | |
| parent | a529c144569d3adf41a628368e09b83c48af11d8 (diff) | |
| download | bin.sh-ce18a33847d49a867c7f63d364f252aecb8831aa.tar.xz | |
bin/tmux-session.sh: check for comment and empty line
If the line in .tmux.session file is empty or start with "#", skip it.
Also, split the line into array and read only the first column for name
and second column for directory, which allow the rest of line as comment.
| -rwxr-xr-x | bin/tmux-session.sh | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/tmux-session.sh b/bin/tmux-session.sh index 774e64b..d12aafa 100755 --- a/bin/tmux-session.sh +++ b/bin/tmux-session.sh @@ -11,8 +11,8 @@ ## ## name-1 directory ## name-2 directory -## ... -## name-n directory +## # comment +## name-n directory # inline comment ## ## Where name is unique string between each line, and directory is a path to ## directory where session will started. @@ -33,9 +33,16 @@ fi echo "searching for $SESS_NAME ..." { - while read name dir; do - if [[ "$SESS_NAME" == "$name" ]]; then - SESS_DIR=$dir + while read line; do + if [[ -z "$line" ]]; then + continue + fi + if [[ "$line" =~ ^#.* ]]; then + continue + fi + session=($line) + if [[ "$SESS_NAME" == "${session[0]}" ]]; then + SESS_DIR="${session[1]}" break fi done |
