brew install tmux
brew install reattach-to-user-namespace # to make tmux's copy to clipboard possible
brew install vim # upgrade vim to 7.4 to make copy to clipboard available
# git_hipster
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
curl -OL http://github.com/git/git/raw/master/contrib/completion/git-completion.bash
mv ~/git-completion.bash ~/.git-completion.bash
Git hipster is from My's Gist
Open ~/.bash_profile
and add:
# Ruby version picker
eval "$(rbenv init -)"
# Git config
color constant
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
LIME_YELLOW=$(tput setaf 190)
POWDER_BLUE=$(tput setaf 153)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
source ~/.git-prompt.sh
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
export PS1='\W\[${LIME_YELLOW}\]$(__git_ps1 "(%s)")\[${NORMAL}\] > '
fi
# Custom shell function
source ~/.bash_custom
Open ~/.bash_custom
and add:
# Export
export PATH="/usr/local/bin:$PATH"
export EDITOR='vim'
# Alias
## github page - jekyll serve
alias ghpjks='bundle exec jekyll serve'
## source .bash_profile
alias srcbpf='source ~/.bash_profile'
alias srcz='source ~/.zshrc'
## hide & show files
alias unhideFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
## directory shortcuts
alias projectDir='cd /Users/tulakan/OneDrive/Projects'
alias unityDir='cd ~/LocalProjects/unity3d'
## command
alias l='ls -tlcras'
alias s='du -sh'
##########
# App shortcuts
## Safari
safari() {
open -a Safari.app "$1"
}
## Chrome
chrome() {
open -a "Google Chrome.app" "$1"
}
## Preview
preview() {
open -a Preview.app "$1"
}
## VS Code
code() {
if [[ $# = 0 ]];
then
echo $PWD
open -a "Visual Studio Code" $PWD
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
echo $F
open -a "Visual Studio Code" $F
fi
}
##########
# Some useful stuffs
## Song Trimmer
## trimmer <song> <start(sec)> <duration(sec)>
trimmer() {
ffmpeg -i "$1" -ss "$2" -t "$3" -acodec copy cut_"$1"
}
##########
# youtube-dl add-on
## due to certification error, this alias is to bypass
chk-ytdl-dir() {
if [ ! -d ~/Music/youtube-dl ]; then
mkdir ~/Music/youtube-dl
echo "created ~/Music/youtube-dl"
fi
}
ytdl() {
## checking
testlen=$1
if [[ $# -gt 2 ]]; then
echo "Only 2 arguments are allowed!"
return 1
fi
if [[ ${#testlen} -gt 4 ]]; then
echo "Maximum length of option is 4.. (-sph or -vph)"
return 1
fi
if [[ $1 == *"s"* && $1 == *"v"* ]]; then
echo "Could not download both song and video at once!"
return 1
fi
## downloading
chk-ytdl-dir
curdir="$PWD"
if [[ $1 != *"h"* ]]; then
cd ~/Music/youtube-dl/
else
echo "Download to current path.."
fi
if [[ $1 == *"s"* ]]; then
echo "Downloading song.."
if [[ $1 == *"p"* ]]; then
echo "With proxy.."
youtube-dl -o "%(title)s.%(ext)s" -f "m4a" --proxy "" --no-check-certificate $2
else
youtube-dl -o "%(title)s.%(ext)s" -f "m4a" --no-check-certificate $2
fi
elif [[ $1 == *"v"* ]]; then
echo "Downloading video.."
if [[ $1 == *"p"* ]]; then
echo "With proxy.."
youtube-dl -o "%(title)s.%(ext)s" -f "best" --proxy "" --no-check-certificate $2
else
youtube-dl -o "%(title)s.%(ext)s" -f "best" --no-check-certificate $2
fi
else
echo "No satisfied parameters filled.."
echo "Please use -s for song, -v for video, -p if proxy and -h to save to current path."
fi
cd $curdir
}
chk-dup-song() {
fdupes -r -d ~/Music/youtube-dl/
}
Open ~/.tmux.conf
and add:
## BASIC STUFFS
# using ` as prefix
unbind C-b
set-option -g prefix `
bind ` send-prefix
# change split keys
unbind %
bind - split-window -v
unbind '"'
bind | split-window -h
# easily source .tmux.conf
unbind r
bind-key r source-file ~/.tmux.conf \; \
display-message "source-file done"
#count windows and panes from 1
set -g base-index 1
setw -g pane-base-index 1
## MOUSE
set -g mode-mouse on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on
## COLOR
set -g default-terminal "screen-256color"
## PASTE BUFFER TO CLIPBOARD
# Copy-paste integration
set-option -g default-command "reattach-to-user-namespace -l bash"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# Bind ']' to use pbpaste
bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
# Kill session
bind k confirm-before -p "kill-session #S? (y/n)" kill-session
Open ~/.vimrc
and add:
set clipboard=unnamed
syntax on
set background=dark
filetype plugin on
set omnifunc=syntaxcomplete#Complete
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab