From 499b0f4329145a6096b33919b021065865ba902c Mon Sep 17 00:00:00 2001 From: oliverhnat Date: Sat, 4 Oct 2025 15:46:47 +0200 Subject: [PATCH] fix(tmuxinator): make grep safe + running just mx will open in the current directory --- omz-custom/tmux-sessions.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/omz-custom/tmux-sessions.sh b/omz-custom/tmux-sessions.sh index ffb27c0..047cd23 100644 --- a/omz-custom/tmux-sessions.sh +++ b/omz-custom/tmux-sessions.sh @@ -1,12 +1,8 @@ function mx() { - PROJECT_DIR=$1 - if [[ -z "$PROJECT_DIR" ]]; then - echo "Usage: mx [SESSION_NAME]" - return 1 - fi - + PROJECT_DIR=${1:-.} + SAFE_INPUT=$(printf '%s\n' "$PROJECT_DIR" | sed 's/[][\.^$*+?{}|()]/\\&/g') ALL_PROJECTS=$(get_mux_sessions) - IS_VALID_PROJECT=$(echo $ALL_PROJECTS | grep -o "\b$PROJECT_DIR\w*" | head -1) + IS_VALID_PROJECT=$(echo $ALL_PROJECTS | grep -o "[[:<:]]$SAFE_INPUT\w*" | head -1) if [[ $IS_VALID_PROJECT != "" ]]; then tmuxinator start "$IS_VALID_PROJECT" return 1