diff --git a/pkgs/ref-irc/default.nix b/pkgs/ref-irc/default.nix index 89008a0..e2e7fd0 100644 --- a/pkgs/ref-irc/default.nix +++ b/pkgs/ref-irc/default.nix @@ -5,7 +5,7 @@ writeShellApplication { name = "ref-irc"; - runtimeInputs = [pkgs.tmux pkgs.gnugrep pkgs.weechat-unwrapped]; + runtimeInputs = [pkgs.tmux pkgs.weechat-unwrapped]; text = builtins.readFile ./script.sh; } diff --git a/pkgs/ref-irc/script.sh b/pkgs/ref-irc/script.sh index 11d5870..edeebbd 100644 --- a/pkgs/ref-irc/script.sh +++ b/pkgs/ref-irc/script.sh @@ -4,8 +4,8 @@ SESSION_NAME="irc" SESSION_DIR="$HOME" SESSION_CMD="weechat" -if ! tmux list-session | grep -q "$SESSION_NAME"; then - tmux new-session -d -s "$SESSION_NAME" -c "$SESSION_DIR" "$SESSION_CMD" +if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then + tmux new-session -d -s "$SESSION_NAME" -c "$SESSION_DIR" "$SESSION_CMD" fi tmux switch-client -t "$SESSION_NAME" diff --git a/pkgs/ref-mail/default.nix b/pkgs/ref-mail/default.nix index 11866da..80533c7 100644 --- a/pkgs/ref-mail/default.nix +++ b/pkgs/ref-mail/default.nix @@ -5,7 +5,7 @@ writeShellApplication { name = "ref-mail"; - runtimeInputs = [pkgs.tmux pkgs.gnugrep pkgs.neomutt pkgs.lynx]; + runtimeInputs = [pkgs.tmux pkgs.neomutt pkgs.lynx]; text = builtins.readFile ./script.sh; } diff --git a/pkgs/ref-mail/script.sh b/pkgs/ref-mail/script.sh index 9db67ac..47b99c9 100644 --- a/pkgs/ref-mail/script.sh +++ b/pkgs/ref-mail/script.sh @@ -4,7 +4,7 @@ SESSION_NAME="mail" SESSION_DIR="$HOME/.Mail/private" SESSION_CMD="neomutt" -if ! tmux list-session | grep -q "$SESSION_NAME"; then +if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then tmux new-session -d -s "$SESSION_NAME" -c "$SESSION_DIR" "$SESSION_CMD" fi diff --git a/pkgs/ref-main/default.nix b/pkgs/ref-main/default.nix index e4bc3c9..35f9d4a 100644 --- a/pkgs/ref-main/default.nix +++ b/pkgs/ref-main/default.nix @@ -11,7 +11,7 @@ writeShellApplication { name = "ref-main"; - runtimeInputs = [pkgs.tmux pkgs.gnugrep]; + runtimeInputs = [pkgs.tmux]; # excludeShellChecks = [ "SC2148" ]; text = builtins.readFile ./script.sh; diff --git a/pkgs/ref-main/script.sh b/pkgs/ref-main/script.sh index 4b60cba..8e709c4 100644 --- a/pkgs/ref-main/script.sh +++ b/pkgs/ref-main/script.sh @@ -3,13 +3,13 @@ SESSION_NAME="main" SESSION_DIR="$HOME" -if ! tmux server-info > /dev/null 2>&1; then - tmux new-session -s "$SESSION_NAME" -c "$SESSION_DIR" - exit 0 +if ! tmux server-info >/dev/null 2>&1; then + tmux new-session -s "$SESSION_NAME" -c "$SESSION_DIR" + exit 0 fi -if ! tmux list-session | grep -q "$SESSION_NAME"; then - tmux new-session -d -s "$SESSION_NAME" -c "$SESSION_DIR" +if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then + tmux new-session -d -s "$SESSION_NAME" -c "$SESSION_DIR" fi tmux switch-client -t "$SESSION_NAME"