Skip to content

Commit

Permalink
Add script for creating tmux session from ghq projects
Browse files Browse the repository at this point in the history
Also bind it in tmux to run it with a shortcut.
  • Loading branch information
bzf committed Sep 18, 2021
1 parent 6079135 commit 5bd002e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bin/create-session-from-ghq-project
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# set -e
set -x

SELECTED_PROJECT_PATH=$(find ~/ghq -type d -maxdepth 3 -mindepth 3 | fzf)
SESSION_NAME=$(echo $SELECTED_PROJECT_PATH | awk -F '/' '{print $NF}')

echo $SELECTED_PROJECT_PATH
echo $SESSION_NAME

tmux has-session -t $SESSION_NAME

if [ $? != 0 ]; then
tmux new-session -d -s $SESSION_NAME -c $SELECTED_PROJECT_PATH
fi

tmux switch-client -t $SESSION_NAME
2 changes: 2 additions & 0 deletions tmux.conf
Expand Up @@ -17,6 +17,8 @@ bind-key - split-window -v -c "#{pane_current_path}"
bind-key \\ split-window -h -c "#{pane_current_path}"
bind-key c new-window -c "#{pane_current_path}"

bind-key h new-window "~/.bin/create-session-from-ghq-project"

set-option -g base-index 1
set-option -g renumber-windows on

Expand Down

0 comments on commit 5bd002e

Please sign in to comment.