Skip to content

Commit

Permalink
fix: reattaching to git root sessions (#62)
Browse files Browse the repository at this point in the history
* chore: add words to dictionary
* fix: git root logic when reattaching to existing sessions
  • Loading branch information
joshmedeski authored Oct 10, 2023
1 parent 6539f49 commit 5be9523
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
18 changes: 6 additions & 12 deletions bin/t
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,17 @@ fi

zoxide add "$RESULT" &>/dev/null # add to zoxide database

if [[ $T_SESSION_USE_GIT_ROOT == 'true' ]]; then
GIT_ROOT=$(
git -C $RESULT rev-parse --show-toplevel
)
if [[ $? -ne 0 ]]; then
if [[ $RESULT != /* ]]; then # not folder path from zoxide result
SESSION_NAME=$RESULT
elif [[ $T_SESSION_USE_GIT_ROOT == 'true' ]]; then
GIT_ROOT=$(git -C $RESULT rev-parse --show-toplevel 2>/dev/null) && echo $GIT_ROOT >/dev/null
if [[ $? -ne 0 ]]; then # not inside git repository
SESSION_NAME=$(basename "$RESULT" | tr ' .:' '_')
else
else # is in git repository
BASENAME=$(basename $GIT_ROOT)
echo 'Git root:' >>/tmp/tmux-t.log
echo $GIT_ROOT >>/tmp/tmux-t.log
RELATIVE_PATH=${RESULT#$GIT_ROOT}
echo 'relative path:' >>/tmp/tmux-t.log
echo $RELATIVE_PATH >>/tmp/tmux-t.log
SEPARATOR="/"
FORMATTED_PATH="${RELATIVE_PATH//\//$SEPARATOR}"
echo 'formatted path:' >>/tmp/tmux-t.log
echo $FORMATTED_PATH >>/tmp/tmux-t.log
SESSION_NAME=$(echo $BASENAME$FORMATTED_PATH | tr ' .:' '_')
fi
elif [[ $T_SESSION_NAME_INCLUDE_PARENT == 'true' ]]; then
Expand Down
15 changes: 12 additions & 3 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"language": "en",
"flagWords": [],
"words": ["zoxide", "maxdepth", "esac", "RUNTYPE", "joshmedeski", "btab"],
"version": "0.2"
"version": "0.2",
"language": "en",
"words": [
"btab",
"elif",
"esac",
"joshmedeski",
"maxdepth",
"RUNTYPE",
"toplevel",
"zoxide"
]
}

0 comments on commit 5be9523

Please sign in to comment.