change basename to rev-parse
This commit is contained in:
parent
d4b9114eee
commit
d610b5cd0e
1 changed files with 14 additions and 5 deletions
|
|
@ -1,13 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
branch_name=$(basename $1)
|
||||
# Get the branch name without using 'basename'
|
||||
branch_name=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
# Set up tmux
|
||||
session_name=$(tmux display-message -p "#S")
|
||||
clean_name=$(echo $branch_name | tr "./" "__")
|
||||
clean_name=$(echo "$branch_name" | tr "./" "__")
|
||||
target="$session_name:$clean_name"
|
||||
|
||||
if ! tmux has-session -t $target 2> /dev/null; then
|
||||
tmux neww -dn $clean_name
|
||||
# Start tmux server if not already running
|
||||
if [ -z "$(tmux list-sessions 2>/dev/null)" ]; then
|
||||
tmux new-session -d -s "$session_name"
|
||||
fi
|
||||
|
||||
# Create a new window if it doesn't exist
|
||||
if [ -z "$(tmux list-windows -t "$session_name" | grep "$clean_name")" ]; then
|
||||
tmux neww -dn "$clean_name"
|
||||
fi
|
||||
|
||||
shift
|
||||
tmux send-keys -t $target "$*"
|
||||
tmux send-keys -t "$target" "$*"
|
||||
|
|
|
|||
Loading…
Reference in a new issue