fix(tmuxinator): make grep safe + running just mx will open in the current directory
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
function mx() {
|
function mx() {
|
||||||
PROJECT_DIR=$1
|
PROJECT_DIR=${1:-.}
|
||||||
if [[ -z "$PROJECT_DIR" ]]; then
|
SAFE_INPUT=$(printf '%s\n' "$PROJECT_DIR" | sed 's/[][\.^$*+?{}|()]/\\&/g')
|
||||||
echo "Usage: mx <project_directory> [SESSION_NAME]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ALL_PROJECTS=$(get_mux_sessions)
|
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
|
if [[ $IS_VALID_PROJECT != "" ]]; then
|
||||||
tmuxinator start "$IS_VALID_PROJECT"
|
tmuxinator start "$IS_VALID_PROJECT"
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user