Skip to content

Instantly share code, notes, and snippets.

@thykka
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save thykka/3f650b0eec9102311a11 to your computer and use it in GitHub Desktop.

Select an option

Save thykka/3f650b0eec9102311a11 to your computer and use it in GitHub Desktop.
My OS X dotfiles
alias l="ls"
alias ll="ls -FGlAhp"
alias la="ls -a"
alias lla="ls -la"
alias ~="cd ~"
alias c="clear"
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias rm="echo \"You live dangerously, huh?\"; rm"
alias hax='cat /dev/urandom | hexdump | sed -E "s/([A-Fa-f0-9])([A-Fa-f0-9]{6})(.*)/\1x\2: \3 /g"'
alias tm="tmux attach-session -t OSX || tmux new-session -s OSX"
alias cp="cp -iv"
alias mv="mv -iv"
alias mkdir="mkdir -pv"
alias less="less -FSRXc"
# alias top="sudo htop"
# alias htop="sudo htop"
alias myip="curl ip.appspot.com && ipconfig getpacket en0 | grep yiaddr"
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
alias ss="/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine"
alias top="top -R -F -s 10 -o cpu"
alias cpuhogs="watch -n2 \"ps wwaxr -o %cpu,utime,pid,comm | head -10\""
alias memhogs="watch -n3 \"ps wwaxm -o vsize,pid,comm | head -10\""
alias f="open -a Finder ./" # Opens cwd in Finder
alias apacheerror="cat /var/log/apache2/error_log | tail -rn 5"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Custom bash prompt via kirsle.net/wizards/ps1.html
export PS1="\[$(tput setaf 16)\]\u@\[$(tput setaf 4)\]\h: \[$(tput sgr0)\]\W\n\\$ \[$(tput sgr0)\]"
export PS2="> "
# export BLOCKSIZE=1k
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export LS_COLORS="di=1;36;40:ln=1;35;40:so=1;32;40:pi=1;33;40:ex=1;31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=34;43:"
# NVM ->
export NVM_DIR="/Users/thykka/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# <- NVM
# Load some useful aliases
source ~/.bash_aliases
# subl: make sublime text CLI-launcher work within TMUX
# -----------------------------------------------------
subl () {
if [ -n $TMUX ]; then
reattach-to-user-namespace /usr/local/bin/subl $@
else
/usr/local/bin/subl $@
fi
}
# jp: Speak japanese to me!
# --------------------------
jp () {
say -v Kyoko "$*"
}
# mip: Speak and display current external IP
# ------------------------------------------
mip () {
ip=$(curl -s ip.appspot.com)
echo "$ip"
say -v Karen "$ip"
}
# trash: Move files into trash. Use this instead of rm!
# -----------------------------------------------------
trash () {
mv $* ~/.Trash
say -v Kyoko "Files removed"
}
# extract: Extract most know archives with one command
# -----------------------------------------------------
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
}
# spotlight: Search for a file using Spotlight's metadata
# -------------------------------------------------------
sl() { mdfind "kMDItemDisplayName == '$@'wc"; }
# cdf: Navigate to foremost Finder folder
# ---------------------------------------
cdf () {
currFolderPath=$( /usr/bin/osascript <<EOT
tell application "Finder"
try
set currFolder to (folder of the front window as alias)
on error
set currFolder to (path to desktop folder as alias)
end try
POSIX path of currFolder
end tell
EOT
)
echo "cd to \"$currFolderPath\""
cd "$currFolderPath"
}
# Show today's fact!
grep -h $(date "+%m/%d") /usr/share/calendar/calendar.*
# use UTF-8
set -g utf8
set-window-option -g utf8 on
# Goddammit, Sublime!
EDITOR="reattach-to-user-namespace subl -w"
# colors!
set -g default-terminal "screen-256color"
# scrollback history limit
set -g history-limit 5120
# Change default prefix key
set -g prefix C-a
unbind C-b
# use send-prefix to pass C-a through to application
bind C-a send-prefix
# shorten command delay
set -sg escape-time 1
# Window and pane indexes start from 1, not 0
set-option -g base-index 1
setw -g pane-base-index 1
# reload config using prefix > r
bind r source-file ~/.tmux.conf \; display "Config reloaded."
# Some split binds
bind | split-window -h
bind - split-window -v
# Move current to first
bind T swap-window -t 1
# Vi movement as pane movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Cycle through panes with C-h and C-l
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Resize using prefix > HJKL
bind H resize-pane -L 5
bind J resize-pane -D 5
bind K resize-pane -U 5
bind L resize-pane -R 5
# Disable mouse control
setw -g mode-mouse off
set -g mouse-select-pane off
set -g mouse-resize-pane off
set -g mouse-select-window off
# Some colors...
# hilight active
set-option -g pane-border-fg colour235
set-option -g pane-active-border-fg colour240
# colorize CLI
set-option -g message-bg black
set-option -g message-fg brightred
set-option -g status-bg colour235
set-option -g status-fg yellow
set-option -g status-attr dim
set-window-option -g window-status-fg brightblue
set-window-option -g window-status-bg colour236
set-window-option -g window-status-attr dim
set-window-option -g window-status-current-fg brightred
set-window-option -g window-status-current-bg colour236
set-window-option -g window-status-current-attr bright
# Statusbar
set-option -g status on
set -g status-utf8 on
set -g status-interval 5
set -g status-justify centre
set-option -g status-position top
# show host and IP (ext & intra)
set -g status-left-length 70
set -g status-left "#[fg=white]: #h : #[fg=brightwhite]#(curl icanhazip.com) #[fg=red]#(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}')"
# show session name, window & pane number, date and time on right
set -g status-right-length 60
set -g status-right "#[fg=red]#S #I:#P #[fg=white]:: %Y-%m-%d #[fg=brightwhite]:: #(date | awk '{print $4}') "
set nocompatible
set history=512
filetype plugin on
filetype indent on
" Auto refresh when file is updated
set autoread
" Turn WiLd menu on
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
" Always show position
set ruler
" Show line numbers
set number
" Command bar height
set cmdheight=2
" Scroll n lines when cursor leaves screen
set scrolljump=10
" Minimum lines to keep above and below cursor
set scrolloff=3
" Backspace for dummies
set backspace=indent,eol,start
set whichwrap+=<,>,h,l
" Case-insensitive search
set ignorecase
" Try to be smart regarding case
set smartcase
" Highlight search results
set hlsearch
" Incremental search
set incsearch
" No redraw when running macros
set lazyredraw
" Regex magic (what this?)
set magic
" Show and blink matching brackets for 2sec
set showmatch
set mat=2
" Shut up already
set noerrorbells
set t_vb=
set tm=500
set list
set listchars=tab:>.,trail:.,extends:\#,nbsp:. " Highlight problematic WS
" " " " " " " " " " " " " " "
"=> C o l o r s & F o n t s "
" " " " " " " " " " " " " " "
set t_Co=256
colorscheme ir_black
set background=dark
" Syntax highlighting
syntax enable
" UTF8 default
set encoding=utf8
" Highlight current line
set cursorline
hi CursorLine cterm=NONE ctermbg=23
" Highlight current column
" set cursorcolumn
" hi CursorColumn cterm=NONE ctermbg=23
" Unix standard filetype
set ffs=unix,dos,mac
" " " " " " " " " " " " " " " " " " "
"=> F i l e s, b a c k u p, u n d o "
" " " " " " " " " " " " " " " " " " "
" Backups off, better use VC!
set nobackup
set nowb
set noswapfile
" " " " " " " " " " " " " " " " "
"=> T e x t, t a b, i n d e n t "
" " " " " " " " " " " " " " " " "
" Spaces instead of tabs
set expandtab
" be smart
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Line break for loooong lines
set lbr
set tw=512
set ai " Auto indent
set si " Smart indent
set wrap " Wrap lines
" " " " " " " " " " " " " "
"=> V i s u a l m o d e "
" " " " " " " " " " " " " "
" " " " " " " " " " " " " " " " " " " " " " " " " " " " " "
"=> W i n d o w, t a b, b u f f e r n a v i g a t i o n "
" " " " " " " " " " " " " " " " " " " " " " " " " " " " " "
" Move by visual line
nnoremap j gj
nnoremap k gk
" Move to line beginning/end
nnoremap B ^
nnoremap E $
" ...and remove old bindings
nnoremap ̭$ <nop>
nnoremap ^ <nop>
" Highlight last inserted text
nnoremap gV `[v`]
" Space is search
map <space> /
" Allow cursor beyond last char
set virtualedit=onemore
" Return to last edit position when opening file
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember open buffers on close
set viminfo^=%
" " " " " " " " " " " " "
"=> S t a t u s l i n e "
" " " " " " " " " " " " "
" Sometimes show
if has('statusline')
set laststatus=2
set statusline=%<%f " Filename
set statusline+=%w%h%m%r " Options
"set statusline+=\\ [%{&ff}/%Y] " Filetype
"set statusline+=\\ [%{getcwd()}] " CWD
"set statusline+=\\ [A=\\%03.3b/H=\\%02.2B] " ASCII/Hex of char
set statusline+=%=%-14.(%l,%c%V%) " Right aligned nav info
endif
" Display current mode
set showmode
" " " " " " " " " " " " " " " " " " "
"=> E d i t i n g m a p p i n g s "
" " " " " " " " " " " " " " " " " " "
" Delete trailing WS on save
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.?css :call DeleteTrailingWS()
autocmd BufWrite *.html :call DeleteTrailingWS()
autocmd BufWrite *.js :call DeleteTrailingWS()
autocmd BufWrite *.vimrc :call DeleteTrailingWS()
" " " " " " " " " "
"=> H e l p e r s "
" " " " " " " " " "
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment