Created
October 7, 2014 11:53
-
-
Save rsslldnphy/3c8119d5023b0268a27e to your computer and use it in GitHub Desktop.
OSX, TMUX, VIM... *and* copy and paste
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set-option -g default-command "reattach-to-user-namespace -l bash" # <- supposed to sort it globally, but doesn't always work for me | |
# Smart pane switching with awareness of vim splits | |
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-h) || tmux select-pane -L" | |
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-j) || tmux select-pane -D" | |
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-k) || tmux select-pane -U" | |
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys C-l) || tmux select-pane -R" | |
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)g?(view|n?vim?)(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l" | |
bind k confirm kill-session | |
bind C-k confirm kill-session | |
unbind C-b | |
set -g prefix C-g | |
bind C-g send-prefix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# I use this script for starting up a clojure project with a running repl and autorunnning tests in the background | |
PROJECT_NAME=`basename $(pwd)` | |
PROJECT_DIR=`pwd` | |
NREPL_PORT=$(cat .nrepl-port 2> /dev/null || echo 8000) | |
echo "" | |
echo "*************************************************************" | |
echo "******************* IT'S CLOJURE TIME! **********************" | |
echo "*************************************************************" | |
echo "" | |
echo "Setting up workspace for the $PROJECT_NAME project." | |
echo -n "Loading NREPL on port $NREPL_PORT." | |
say "Its Clojur time!" | |
tmux has-session -t $PROJECT_NAME &> /dev/null | |
if [ $? != 0 ] ; then | |
tmux new-session -s $PROJECT_NAME -n script -d | |
tmux rename-window "$PROJECT_NAME-CODE" | |
tmux new-window -n "$PROJECT_NAME-REPL" "cd $PROJECT_DIR && LEIN_REPL_PORT=$NREPL_PORT lein repl" | |
tmux new-window -n "$PROJECT_NAME-TESTS" "cd $PROJECT_DIR; lein autoexpect" | |
tmux select-window -t "$PROJECT_NAME-CODE" | |
tmux send-keys "cd $PROJECT_DIR; reattach-to-user-namespace -l vim project.clj" C-m # this is the crucial call to reattach-to-user-namespace | |
say "Loading n repple on port $NREPL_PORT" | |
while ! nc -z localhost $NREPL_PORT; do echo -n '.'; say "cough"; sleep 1; done | |
say "phew, finally. lets hack on $PROJECT_NAME" | |
echo "" | |
tmux send-keys ":Connect nrepl://localhost:$NREPL_PORT" C-m C-m | |
fi | |
tmux bind r select-window -t "$PROJECT_NAME-REPL" | |
tmux bind t select-window -t "$PROJECT_NAME-TESTS" | |
tmux bind c select-window -t "$PROJECT_NAME-CODE" | |
tmux attach -t $PROJECT_NAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install reattach-to-user-namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment