Skip to content

Instantly share code, notes, and snippets.

@fidiego
Last active November 20, 2017 18:03
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 fidiego/356d87d167d139d986e0762cee8ddd8b to your computer and use it in GitHub Desktop.
Save fidiego/356d87d167d139d986e0762cee8ddd8b to your computer and use it in GitHub Desktop.
Dotfiles - The structure and content of my dotfiles
[alias]
br = branch
co = checkout
lg = log --color --date=local --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit
log = log --topo-order --decorate
st = status -sb
up = fetch --all --prune
pup = !git fetch --all --prune && git pull
[diff]
renames = copy
[color]
branch = auto
diff = auto
interactive = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
frag = magenta bold
meta = yellow bold
new = green bold
old = red bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[core]
whitespace = space-before-tab,trailing-space,cr-at-eol
ignorecase = false
[fetch]
prune = true
[pack]
threads = 0
[push]
default = current
# Configs
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
###
# ALIASES
###
# Monitor Aliases
alias laptop 1280x800
#alias aoc
bind left:ctrl;alt throw next
bind right:ctrl;alt throw next
####
# Resize Bindings
####
# Full Screen
bind m:cmd;alt;ctrl push right bar-resize:screenSizeX
# Half Size
bind right:cmd;alt;ctrl push right bar-resize:screenSizeX/2
bind left:cmd;alt;ctrl push left bar-resize:screenSizeX/2
bind down:cmd;alt;ctrl push down bar-resize:screenSizeY/2
bind up:cmd;alt;ctrl push up bar-resize:screenSizeY/2
# Quarter Size
bind right:cmd;alt;shift corner bottom-right resize:screenSizeX/2;screenSizeY/2
bind left:cmd;alt;shift corner top-left resize:screenSizeX/2;screenSizeY/2
bind down:cmd;alt;shift corner bottom-left resize:screenSizeX/2;screenSizeY/2
bind up:cmd;alt;shift corner top-right resize:screenSizeX/2;screenSizeY/2
###
# Hints
###
bind esc:cmd hint
# Switch currently doesn't work well so I'm commenting it out until I fix it.
# bind tab:cmd switch
# set Zsh as your default Tmux shell
set-option -g default-shell /bin/zsh
# set to vi mode
set-window-option -g mode-keys vi
# Tmux should be pretty, we need 256 color for that
set -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on
# command delay? We don't want that, make it short
set -sg escape-time 1
# Change cursor in vim to distinguish between insert and command mode
set-option -g terminal-overrides '*88col*:colors=88,*256col*:colors=256,xterm*:XT:Ms=\E]52;%p1%s;%p2%s\007:Cc=\E]12;%p1%s\007:Cr=\E]112\007:Cs=\E]50;CursorShape=%?%p1%{3}%<%t%{0}%e%p1%{2}%-%;%d\007'
# Allow us to reload our Tmux configuration while using Tmux
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# bind HJKL to pane switching
# bind -r -n C-h select-pane -L
# bind -r -n C-j select-pane -D
# bind -r -n C-k select-pane -U
# bind -r -n C-l select-pane -R
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# for moving tabs around
# source: https://superuser.com/questions/343572/how-do-i-reorder-tmux-windows/552493#552493
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
# Footer coloring
set -g default-terminal "screen-256color"
set -g status-bg blue
set -g status-fg black
set -g status-justify left
set -g status-interval 1
# messaging
set -g message-fg black
set -g message-bg yellow
set -g message-command-fg blue
set -g message-command-bg black
#window mode
setw -g mode-bg colour6
setw -g mode-fg colour0
# window status
setw -g window-status-format " #F#I:#W#F "
setw -g window-status-current-format " #F#I:#W#F "
setw -g window-status-format "#[fg=magenta]#[bg=black] #I #[bg=cyan]#[fg=colour8] #W "
setw -g window-status-current-format "#[bg=brightmagenta]#[fg=colour8] #I #[fg=colour8]#[bg=colour14] #W "
setw -g window-status-current-bg colour0
setw -g window-status-current-fg colour11
setw -g window-status-current-attr dim
setw -g window-status-bg green
setw -g window-status-fg black
setw -g window-status-attr reverse
# Info on left (I don't have a session display for now)
set -g status-left ''
# loud or quiet?
set-option -g visual-activity off
set-option -g visual-bell off
set-option -g visual-silence off
set-window-option -g monitor-activity off
set-option -g bell-action none
set -g default-terminal "screen-256color"
# The modes {
setw -g clock-mode-colour colour135
setw -g mode-attr bold
setw -g mode-fg colour196
setw -g mode-bg colour238
# }
# The panes {
set -g pane-border-bg colour235
set -g pane-border-fg colour238
set -g pane-active-border-bg colour236
set -g pane-active-border-fg colour51
# }
# The statusbar {
set -g status-position bottom
set -g status-bg colour234
set -g status-fg colour137
set -g status-attr dim
set -g status-left ''
set -g status-right '#[fg=black,bg=white,bold] %d/%m/%y #[fg=white,bg=black,bold] %H:%M:%S '
set -g status-right-length 50
set -g status-left-length 20
setw -g window-status-current-fg colour81
setw -g window-status-current-bg colour238
setw -g window-status-current-attr bold
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '
setw -g window-status-fg colour138
setw -g window-status-bg colour235
setw -g window-status-attr none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-attr bold
setw -g window-status-bell-fg colour255
setw -g window-status-bell-bg colour1
# }
# The messages {
set -g message-attr bold
set -g message-fg colour232
set -g message-bg colour166
# }
" load pathogen
execute pathogen#infect()
"""
""" General
"""
colorscheme monokai
" leader
" follow the leader
let mapleader = ","
let g:mapleader = ","
" never in my life have i used ex mode
nnoremap Q <nop>
" ruler
set ruler
" set line under cursor
set cursorline
" copy to clipboard
set clipboard=unnamed
" fold
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
" turn highlighting on
set hlsearch
" autoread/autoreload changed files
" I git rebase a lot so this is useful
set autoread
" other stuff
set background=dark
set expandtab
set modeline
set number
syntax on
filetype indent plugin on
"""
""" Javascript settings
"""
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2
" prettier lint files on save
autocmd BufWritePre *.js Neoformat
autocmd BufWritePre *.jsx Neoformat
autocmd FileType javascript set formatprg=prettier\ --stdin\ --single-quote=true\ --parser=babylon\ --bracket-spacing\ --print-width=100\ --tab-width=2\ --trailing-comma=es5
let g:neoformat_try_formatprg = 1
" if we want this to fire more often (on edits etc)
" autocmd BufWritePre,TextChanged,InsertLeave *.js Neoformat
"""
""" Python Settings
"""
autocmd FileType python set shiftwidth=4 softtabstop=4 tabstop=4
" highlight all python syntax
let python_highlight_all = 1
let g:syntastic_python_checkers=['flake8']
""" HTML Settings
" html autocomplete
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
" ctrl p settings
let g:ctrlp_working_path_mode = 'a'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
" nerd tree settings
let NERDTreeIgnore = ['\.pyc$']
map <C-n> :NERDTreeToggle<CR>
" nerdcommneter settings
""" Trim Whitespace on Save
" White space noise
function TrimWhiteSpace()
%s/\s*$//
''
:endfunction
set list listchars=tab:»·,trail:·
autocmd FileWritePre * call TrimWhiteSpace()
autocmd FileAppendPre * call TrimWhiteSpace()
autocmd FilterWritePre * call TrimWhiteSpace()
autocmd BufWritePre * call TrimWhiteSpace()
map <F2> :call TrimWhiteSpace()<CR>
map! <F2> :call TrimWhiteSpace()<CR>
""" Rainbow Parens Configs
let g:rainbow_conf = {
\ 'guifgs': ['firebrick', 'seagreen3', 'darkorange3', 'royalblue3'],
\ 'ctermfgs': ['lightmagenta', 'lightblue', 'lightyellow', 'lightcyan'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
" rainbow parenthesis
let g:rainbow_active = 1
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/freddiego/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="my-theme"
# 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)
plugins+=(k)
# source the thing
source $ZSH/oh-my-zsh.sh
#
# User configuration
#
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 -v'
fi
# ssh
export SSH_KEY_PATH="~/.ssh/dsa_id"
# aliases
source ~/.dotfiles/aliases.sh
# paths
source ~/.dotfiles/paths.sh

Dotfiles

zsh

I used to keep everything in ~/.bash_profile but then I started using zsh and I took the opportunity to clean house.

I've split up the contents of ~/.bash_profile into the contents of ~/.dotfiles:

>> tree ~/.dotfiles                                                                                                                                                                                                                  13:35:09
/Users/freddiego/.dotfiles
├── aliases.sh
├── my-theme.zsh-theme
└── paths.sh

I then source the relevant bits in .zshrc

oh-my-zsh

I cannibalized a theme () and made my-theme.

tmux

git

TODO

  • vim
#!/usr/bin/env zsh
########## COLORS ###########
for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
PR_RESET="%{$reset_color%}"
GREEN_BASE_START="${PR_RESET}${PR_GREEN}>>${PR_RESET}"
GREEN_START_P1="${PR_RESET}${GREEN_BASE_START}${PR_RESET} "
DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
VCS_DIRTY_COLOR="${PR_RESET}${PR_YELLOW}"
VCS_CLEAN_COLOR="${PR_RESET}${PR_GREEN}"
VCS_SUFIX_COLOR="${PR_RESET}${PR_RED}› ${PR_RESET}"
# ########## COLOR ###########
# ########## GIT ###########
ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹git:"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘ ${VCS_SUFIX_COLOR}"
ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔ ${VCS_SUFIX_COLOR}"
ZSH_THEME_GIT_PROMPT_ADDED="${PR_RESET}${PR_YELLOW} ✚ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_RESET}${PR_YELLOW} ✹ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_RENAMED="${PR_RESET}${PR_YELLOW} ➜ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_RESET}${PR_YELLOW} ═ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_RESET}${PR_YELLOW} ✭ ${PR_RESET}"
# ########## GIT ###########
# Context: user@directory or just directory
prompt_context () {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
echo -n "${PR_RESET}${PR_GREEN}$USER${PR_RESET}@${PR_CYAN}%m${PR_RESET} %~% ${PR_RESET}"
else
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW} %~% ${PR_RESET}"
fi
}
set_prompt () {
# required for the prompt
setopt prompt_subst
autoload zsh/terminfo
# ######### PROMPT #########
PROMPT='${PR_RED}%D{%d-%m-%Y}${PR_RESET} : ${PR_YELLOW}%D{%u}${PR_RESET} ${PR_CYAN}$(git_prompt_info)${PR_RESET}
$(prompt_context)
${GREEN_START_P1}'
RPROMPT='omg hello'
RPROMPT='${PR_GREEN} %*${PR_RESET}'
# ######### PROMPT #########
}
set_prompt
#!/usr/bin/env zsh
# #
# # #README
# #
########## COLOR ###########
for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
PR_RESET="%{$reset_color%}"
GREEN_BASE_START="${PR_RESET}${PR_GREEN}>> ${PR_RESET}"
GREEN_START_P1="${PR_RESET}${GREEN_BASE_START}${PR_RESET}"
DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
VCS_DIRTY_COLOR="${PR_RESET}${PR_YELLOW}"
VCS_CLEAN_COLOR="${PR_RESET}${PR_GREEN}"
VCS_SUFIX_COLOR="${PR_RESET}${PR_RED}› ${PR_RESET}"
# ########## COLOR ###########
# ########## GIT ###########
ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RESET}${PR_RED}‹git:"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘ ${VCS_SUFIX_COLOR}"
ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔ ${VCS_SUFIX_COLOR}"
ZSH_THEME_GIT_PROMPT_ADDED="${PR_RESET}${PR_YELLOW} ✚ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_RESET}${PR_YELLOW} ✹ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_RENAMED="${PR_RESET}${PR_YELLOW} ➜ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_RESET}${PR_YELLOW} ═ ${PR_RESET}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_RESET}${PR_YELLOW} ✭ ${PR_RESET}"
# ########## GIT ###########
# Context: user@directory or just directory
prompt_context () {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
echo -n "${PR_RESET}${PR_BLUE}$USER${PR_RESET}@${PR_CYAN}%m${PR_RESET} %~% ${PR_RESET}"
else
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW} %~% ${PR_RESET}"
fi
}
set_prompt () {
# required for the prompt
setopt prompt_subst
autoload zsh/terminfo
# ######### PROMPT #########
PROMPT='${PR_GREEN}%D{%a : %d-%m-%Y}${PR_RESET} : %* ${PR_CYAN}$(git_prompt_info)${PR_RESET}
$(prompt_context)
${GREEN_START_P1}'
# ######### PROMPT #########
}
set_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment