Last active
June 5, 2018 12:31
-
-
Save vjt/1886016 to your computer and use it in GitHub Desktop.
vjt's tmux RVM + ViM IDE setup
This file contains 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/sh | |
# | |
# IDE Session starter - you should save this script as ~/bin/session, make it | |
# executable with chmod +x ~/bin/session, and then make a symlink to it for | |
# every application you want to start. | |
# E.g. ln -s session ~/bin/members creates a "members" symlink, and when you'll issue | |
# "members" on the command line this script will: | |
# Check if a tmux session named "members" exists | |
# If yes, it'll attach it and exit | |
# If no, it'll look for a "members" directory inside the defined base directory below | |
# and for a ".tmuxrc" file inside it. The script then sets the GEM_HOME and GEM_PATH | |
# environment variables, using the RVM environment file (change it if you use rbenv) | |
# and it'll start a new tmux session with the application .tmuxrc file. | |
# I do use a ".gemset" file in each app directory and my .rvmrc contains only | |
# "rvm use `cat .gemset`". In this way only interactive shells will load RVM, | |
# while other shells will live happily without it. | |
# source: https://gist.github.com/1886016 | |
name=`basename $0` | |
base="$HOME/code" | |
dir="$base/$name" | |
rc="$dir/.tmuxrc" | |
if ! test -f $rc; then | |
echo "$rc does not exist" | |
exit -1 | |
fi | |
if ! tmux has-session -t $name ; then | |
# Change this line if you use something different than RVM. | |
# The session needs the GEM_HOME and GEM_PATH variables. | |
source ~/.rvm/environments/`cat $dir/.gemset` | |
tmux start \;\ | |
new-session -d -s $name exit \;\ | |
set default-path $dir \;\ | |
set remain-on-exit on \;\ | |
setenv -t $name PATH $PATH \;\ | |
setenv -t $name GEM_HOME $GEM_HOME \;\ | |
setenv -t $name GEM_PATH $GEM_PATH \;\ | |
source-file $rc \;\ | |
set remain-on-exit off | |
fi | |
tmux attach -t $name |
This file contains 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
# Per-application .tmuxrc. This file is loaded by bin/session | |
# and should be placed into the app root and named .tmuxrc. | |
# | |
# If you do not use pry, replace "pry .." with "rails c" :-). | |
# | |
# vim: syn=tmux | |
# source: https://gist.github.com/1886016 | |
# If you don't need RAILS_RELATIVE_URL_ROOT, just remove it. | |
# | |
neww -n server 'RAILS_RELATIVE_URL_ROOT=/members unicorn -c config/unicorn.development.rb' | |
splitw -v -p 80 'tail -n 200 -f log/development.log' | |
splitw -v -p 30 'pry -r ./config/environment.rb' | |
setw -t server monitor-activity off | |
neww -n app 'vi .' | |
neww -n console 'bash -l' | |
neww -n scm 'bash -l' | |
neww -n gems 'vi $GEM_HOME' | |
# If you've got a single database, you can remove the splitw | |
neww -n db 'rails db' | |
splitw -v -p 50 'sqsh -S debian -U sa -P "" -D database' | |
# | |
selectw -t server |
This file contains 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
# | |
# -*- ~/.tmux.conf -*- | |
# - [email protected] - | |
# | |
# source: https://gist.github.com/1886016 | |
set -g mode-mouse on | |
set -g monitor-activity on | |
set -g repeat-time 200 | |
set -g default-terminal "screen-256color" | |
#set -g clock-mode-style 12 | |
#set -g clock-mode-colour red | |
set -g pane-active-border-fg '#ff0000' | |
set -g status-bg '#0000ff' | |
set -g status-fg '#ffffff' | |
set -g window-status-current-fg '#ff5555' | |
set -g window-status-activity-fg '#ffffff' | |
set -g window-status-activity-bg '#000044' | |
set -g status-right "#W - #T - #(cat /proc/loadavg | awk '{print $1, $2, $3}')" | |
set -g status-right-length 100 | |
set -g status-right-bg '#ff0000' | |
set -g status-right-fg '#ffffff' | |
set -g prefix C-f | |
unbind C-b | |
bind-key C-f send-prefix | |
# C-f C-f switches between the last two windows | |
bind-key C-f last-window | |
bind-key 'f' last-pane | |
bind-key - split-window | |
bind-key | split-window -h | |
bind-key C-l respawn-pane -k | |
unbind-key l | |
unbind-key & | |
bind-key k confirm-before -p "Kill window #W?" kill-window | |
bind-key \ confirm-before -p "Kill session #S?" kill-session | |
bind-key '#' split-window 'htop' | |
bind-key 'm' command-prompt -p "man:" "split-window 'exec man %%'" | |
bind-key 'o' command-prompt -p "ssh:" "split-window 'exec ssh %%'" | |
# Copy tmux buffer into the X clipboard. Requires xsel. | |
# | |
# Copies back data on Mac OS Pasteboard as well, and even over SSH | |
# sessions as long as ForwardX11 (-X / -Y switch) is enabled. | |
bind-key C-c run 'tmux show-buffer | xsel -pbi' |
@jodosha I always try to save keystrokes :) and I find ln -s ~/bin/NAME session
an acceptable tradeoff when starting a new project
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do you need to symlink for each app and not to use like
session members
? Just change frombasename $0
tobasename $1