Skip to content

Instantly share code, notes, and snippets.

@nas
Last active July 23, 2022 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nas/6773719 to your computer and use it in GitHub Desktop.
Save nas/6773719 to your computer and use it in GitHub Desktop.
tmux, vimrc, etc
==========
.tmux.conf
==========
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
set-option -g history-limit 10000
set-window-option -g xterm-keys
set-option -g mouse on
#Set status Bar
set -g status-bg green
set -g status-fg black
set -g status-left '#[fg=brown]#H'
#set-window-option -g window-status-current-bg red
set -g status-right "#[fg=maroon]#(uptime|awk '{print $11}') #(date)"
setw -g monitor-activity on
set -g visual-activity on
#set -g default-terminal "screen-256color" #currently doesnt works with tmux
##CLIPBOARD selection integration
##Requires prefix key before the command key
#Copy tmux paste buffer to CLIPBOARD
bind C-c run "tmux show-buffer | xclip -i -selection clipboard"
#Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer
bind C-v run "tmux set-buffer \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
# quick view of processes
bind '~' split-window "exec htop"
===================
vim bundles/plugins
===================
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
cd ~/.vim/bundle
git clone https://github.com/jgdavey/tslime.vim.git
git clone https://github.com/tpope/vim-rails.git
git clone https://github.com/scrooloose/nerdtree.git
git clone https://github.com/tpope/vim-fugitive.git
git clone https://github.com/Lokaltog/vim-powerline.git
git clone https://github.com/kien/ctrlp.vim.git
git clone https://github.com/tpope/vim-surround.git
git clone https://github.com/epmatsw/ag.vim.git
git clone https://github.com/godlygeek/tabular.git
git clone https://github.com/mattn/vim-gist.git
git clone git://github.com/benmills/vimux.git
git clone git://github.com/jgdavey/vim-turbux.git
git clone git://github.com/vim-scripts/comments.vim.git
git clone git://github.com/tpope/vim-endwise.git #this doesn't work with set paste on
git clone https://github.com/mbbill/undotree.git
git clone https://github.com/fatih/vim-go.git
git clone https://github.com/ngmy/vim-rubocop.git # prerequisite -> gem install rubocop
git clone https://github.com/kylef/apiblueprint.vim.git ~/.vim/bundle/apiblueprint.vim
git clone https://github.com/dense-analysis/ale.git
git clone --depth=1 https://github.com/rust-lang/rust.vim.git
======
.vimrc
======
call pathogen#infect()
" Some Linux distributions set filetype in /etc/vimrc.
" Clear filetype flags before changing runtimepath to force Vim to reload them.
filetype off
filetype plugin indent off
set runtimepath+=/usr/local/go/misc/vim " for go
filetype plugin indent on
syntax on
set incsearch
set hlsearch
set nocompatible
set t_Co=256
let clj_highlight_builtins = 1
" set showcmd
" set ruler
set number
set cc=80
set sw=2 " no of spaces for indenting
set tw=2 " show \t as 2 spaces and treat 2 spaces as \t when deleting, etc..
set foldmethod=syntax
set foldnestmax=10
set list
set wildmenu
set wildmode=full
colorscheme slate
set spell
set tabstop=2
set shiftwidth=2
set expandtab
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
"Invisible character colors
highlight NonText guifg=#4a4a59
highlight SpecialKey guifg=#4a4a59
autocmd BufWritePre *.rb :%s/\s\+$//e
set statusline=
set statusline+=%{fugitive#statusline()} " git branch name
autocmd BufReadPost fugitive://* set bufhidden=delete " clear fugitive buffers
" powerline status
let g:Powerline_symbols = 'unicode'
set laststatus=2
set fillchars+=stl:\ ,stlnc:\
set encoding=utf-8
" key mappings
nmap <silent> <C-D> :NERDTreeToggle<CR>
set runtimepath^=~/.vim/bundle/ctrlp.vim
" Run at Vim's command line -> :helptags ~/.vim/bundle/ctrlp.vim/doc
" Restart Vim and check -> :help ctrlp.txt
" to run specs with rails2 / rspec 1
let g:turbux_command_rspec = 'bundle exec spec'
nnoremap <F5> :UndotreeToggle<cr>
map <C-H> :execute "tabmove" tabpagenr() - 2 <CR>
map <C-J> :execute "tabmove" tabpagenr() <CR>
map <C-T> :set paste<CR>
map <C-O> :set nopaste<CR>
======
.irbrc
======
require 'rubygems'
require 'wirble'
require 'interactive_editor'
Wirble.init
Wirble.colorize
def __; puts Readline::HISTORY.entries; end
unless defined?(reload!)
$files = []
def load!(file)
$files << file
load file
end
def reload!
$files.each { |f| load f }
end
end
=====================
tmux_startup
=====================
#!/bin/sh
tmux new-session -d -s webapp
tmux new-window -t webapp:1 -n 'server-console-memcache'
tmux new-window -t webapp:2 -n 'code'
tmux new-window -t webapp:3 -n 'mysql-job-etc'
tmux new-window -t webapp:4 -n 'test'
tmux new-window -t webapp:5 -n 'misc'
tmux select-window -t webapp:0
tmux -2 attach-session -t webapp
=====================
.bash_profile tidbits
=====================
# START: only work machine related / gotcha's
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin:/usr/local/sbin/:/Users/nasir/.rbenv/bin:/Users/nasir/.rbenv/shims:/Users/nasir/projects/misc/git-whistles/bin
alias reh="eval '$(rbenv init -)';rbenv rehash"
alias app="cd /Users/nasir/projects/*****;reh"
# STOP: only work machine related / gotcha's
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export PATH="/usr/local/homebrew/bin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"
#if not able to install mysql2 gem then set DYLD path env
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
# to install gems in the project vendor/bundle dir
export PATH="./vendor/bundle/bin:$PATH"
alias bi="bundle install --path vendor/bundle --binstubs=vendor/bundle/bin"
alias be="bundle exec"
alias htp="be rake parallel:create[4]; be rake parallel:prepare[4]"
alias hts="htp; be rake parallel:spec[4]"
alias htc="htp; be rake parallel:safe_features[4]"
alias mw="watch -n1 'mysql -uroot --exec=\"SHOW FULL PROCESSLIST\"'"
alias chkdb="git diff origin/master origin/production --stat"
alias gof="git outstanding-features origin/production origin/master"
alias got="git"
alias tm="~/tmux_startup"
alias rmswp="find . -name \*.swp -type f -delete"
alias fswp="find . -name \*.swp -type f"
alias deflate="perl -MCompress::Zlib -e 'undef $/; print uncompress(<>)'"
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_FREE_MIN=500000
export RUBY_HEAP_MIN_SLOTS=40000
export RUBY_GC_HEAP_FREE_SLOTS=500000
export RUBY_GC_HEAP_INIT_SLOTS=40000
export LANG=en_GB.UTF-8
export LC_COLLATE=en_GB.UTF-8
export LC_CTYPE=en_GB.UTF-8
export LC_MESSAGES=en_GB.UTF-8
export LC_MONETARY=en_GB.UTF-8
export LC_NUMERIC=en_GB.UTF-8
export LC_TIME=en_GB.UTF-8
export LC_ALL=en_GB.UTF-8
eval "$(rbenv init -)"
alias datafart='curl --data-binary @- datafart.com'
alias start_mysql='sudo mysqld_safe &'
alias stop_mysql='sudo mysqladmin shutdown'
function mcd() {
mkdir -p "$1" && cd "$1";
}
alias clr='clear;pwd;ls -al'
alias tmps='ps -ef | grep'
alias lf='ls -Gl | grep ^d' #Only list directories
alias lsd='ls -Gal | grep ^d' #Only list directories, including hidden ones
alias gl='git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"'
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
alias clr='clear;pwd;ls -al'
alias memor='ps -o time,ppid,pid,nice,pcpu,pmem,user,comm -A | sort -n -k 6 | tail -15'
# git clone https://gist.github.com/defunkt/1209316
alias gitio='ruby ~/projects/misc/1209316/gitio'
=================
global git config
=================
git config --global alias.list-branch-tests "! git diff --diff-filter=ACMRTUXB --name-only master -- spec test | egrep '_(spec|test).rb' "
# add in .bash_profile for above alias ct="bundle exec spec `git list-branch-tests`"
git config --global user.name "Nasir Jamal"
git config --global user.email "nj@nasir.me.uk"
git config --global github.user "nas"
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.df diff
git config --global alias.lg log
git config --global alias.alog "log --graph --oneline --all"
git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto
git config --global color.ui=auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment