Skip to content

Instantly share code, notes, and snippets.

@wycleffsean
Last active August 29, 2015 14:07
Show Gist options
  • Save wycleffsean/b9a025f042961485cac1 to your computer and use it in GitHub Desktop.
Save wycleffsean/b9a025f042961485cac1 to your computer and use it in GitHub Desktop.
dot files and tools
if [ -r $HOME/.rbenvrc ];
then
source $HOME/.rbenvrc
fi
if [ -r $HOME/.app_vars ];
then
source $HOME/.app_vars
fi
if [ -r $HOME/.app_vars ];
then
source $HOME/.app_vars
fi
if [ -r $HOME/.custom_aliases ];
then
source $HOME/.custom_aliases
fi
if [ -r $HOME/.custom_variables ];
then
source $HOME/.custom_variables
fi
if [ -r $HOME/.custom_functions ];
then
source $HOME/.custom_functions
fi
alias apps="cd /var/apps"
alias gems="cd /var/gems"
alias qa="ssh tk-qa"
alias dqa="ssh deploy@tk-qa"
alias prod="ssh tk-prod"
alias dprod="ssh deploy@tk-prod"
function start_app {
if [ -n "$1" ]
then
app_dir=/var/apps/$1_app
elif [ -x $PWD/script/start.sh ]
then
app_dir=$PWD
elif [ -x $PWD/script/start ]
then
app_dir=$PWD
else
echo "Please provide an app name"
list_apps
return
fi
app_name=$(basename $app_dir)
x=`pwd`
if [ -x $app_dir/script/start.sh ]
then
echo "Starting $app_name..."
cd $app_dir
script/start.sh
echo "Started."
elif [ -x $app_dir/script/start ]
then
echo "Starting $app_name..."
cd $app_dir
script/start
echo "Started."
elif [ -d $app_dir ]
then
echo "Starting $app_name.."
cd $app_dir
bundle exec unicorn -c config/unicorn.rb -E development -D
echo "Started."
else
echo "No such app"
list_apps
fi
cd $x
}
function stop_app {
if [ -n "$1" ]
then
app_dir=/var/apps/$1_app
elif [ -x $PWD/script/stop ]
then
app_dir=$PWD
elif [ -x $PWD/script/stop.sh ]
then
app_dir=$PWD
else
echo "Please provide an app name"
list_apps
return
fi
app_name=$(basename $app_dir)
x=`pwd`
if [ -x $app_dir/script/stop.sh ]
then
echo "Stopping $app_name..."
cd $app_dir
script/stop.sh
echo "Stopped."
elif [ -x $app_dir/script/stop ]
then
echo "Stopping $app_name..."
cd $app_dir
script/stop
echo "Stopped."
elif [ -d $app_dir ]
then
echo "Stopping $app_name..."
cd $app_dir
kill `cat $app_dir/tmp/pids/unicorn.pid` &> /dev/null
echo "Stopped."
else
echo "No such app"
list_apps
fi
cd $x
}
function restart_app {
stop_app $1
start_app $1
}
function list_apps {
echo "Listing apps and their status... [app/worker]"
echo
x=`pwd`
for d in `ls -lGa /var/apps | awk '{print $8}' | tail -n+4`
do
service_app_file=/etc/init.d/$d-app
service_worker_file=/etc/init.d/$d-worker
service_txt='unknown'
worker_txt=''
if [ -d /var/apps/$d ]
then
if [ -f $service_app_file ]
then
$service_app_file status | grep -q 'up and running'
if [ $? -ne 0 ]
then
service_txt="\033[31mdown\033[0m"
else
service_txt="\033[32mup\033[0m"
fi
fi
if [ -f $service_worker_file ]
then
$service_worker_file status | grep -q 'up and running'
if [ $? -ne 0 ]
then
worker_txt="\033[31mdown\033[0m"
else
worker_txt="\033[31mup\033[0m"
fi
fi
if [[ "${#worker_txt}" -lt "1" ]]
then
echo -e "$d [$service_txt]"
else
echo -e "$d [$service_txt/$worker_txt]"
fi
fi
done
cd $x
}
cd /var/apps
function date_prompt() {
$(date +%k:%M:%S)
}
# Custom bash prompt via kirsle.net/wizards/ps1.html
export PS1="\[$(tput bold)\]\[$(tput setaf 3)\]\D{%k:%M:%S} \[$(tput setaf 4)\]\u\[$(tput sgr0)\]:\[$(tput setaf 2)\]\w\[$(tput setaf 5)\]\\$ \[$(tput sgr0)\]"
set laststatus=2
set number
set showcmd
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
set splitbelow
set splitright
if exists('+colorcolumn')
set colorcolumn=80
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
execute pathogen#infect()
syntax on
filetype plugin indent on
let g:airline#extension#tabline#enabled = 1
" let g:ctrlp_map = '<D-p>'
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
let g:ctrlp_use_caching = 0
endif
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ to grep shortcut
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="bureau"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# adjust as needed to fit your dev_ops repo location
export DEV_BOX=$HOME/code/technekes/devbox
alias vup="cd $DEV_BOX;vagrant up --provision;"
alias vhalt="cd $DEV_BOX; vagrant halt;"
alias vssh="cd $DEV_BOX; vagrant ssh;"
alias apps="cd $DEV_BOX/apps"
alias gems="cd $DEV_BOX/gems"
function run_command_on_devbox() {
ssh -p 2222 -i ~/.vagrant.d/insecure_private_key vagrant@localhost "source ~/.bash_profile; $1"
}
function restart_app() {
run_command_on_devbox "restart_app $1"
}
function bundle_app() {
run_command_on_devbox "cd /var/apps/$1_app; bundle; restart_app $1"
}
#export PS1 = "\e[0;93m\[$(date +%k:%M:%S)]\e[0m$PS1"
# Working Directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function install_ag() {
if hash gdate 2>/dev/null; then
return;
else
if hash brew 2>/dev/null; then
brew install the_silver_searcher
else
# build dependencies
apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
# clone to ~/code/the_silver_searcher
mkdir -p ~/code
cd ~/code
git clone https://github.com/ggreer/the_silver_searcher
cd the_silver_searcher && ./build.sh && sudo make install
fi
fi
}
function copy_config() {
cd DIR
cp -i $1 ~/$1
}
# Install Tools
install_ag
# Install Configs
copy_config '.vimrc'
copy_config '.zshrc'
copy_config '.bashrc'
# Install Pathogen (vim package manager)
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
# Install Vim Packages
cd ~/.vim/bundle
git clone https://github.com/kien/ctrlp.vim
git clone https://github.com/bling/vim-airline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment