-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.zshrc
More file actions
119 lines (90 loc) · 2.9 KB
/
.zshrc
File metadata and controls
119 lines (90 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# personal settings loaded before oh-my-zsh
if [[ -a ~/.personal.before.rc ]]; then
source ~/.personal.before.rc
fi
# Set name of the theme to load.
ZSH_THEME="mh"
# zsh plugins
plugins=(git rails ruby rake rbenv bundler mvn ssh-agent tmux)
# turn off auto-updating, it will be handled by .dotfiles
DISABLE_AUTO_UPDATE=true
# load oh-my-zsh
source $ZSH/oh-my-zsh.sh
# personal settings loaded after oh-my-zsh
if [[ -a ~/.personal.after.rc ]]; then
source ~/.personal.after.rc
fi
# make path changes
if [[ -z $TMUX ]]; then
# rbenv
export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"
# use ./bin when it's safe (useful for Spring / tim pope's suggestion)
PATH=".git/safe/../../bin:$PATH"
# add node_modules/.bin to the path
PATH="$HOME/node_modules/.bin:$PATH"
fi
# Base16 Shell
BASE16_SHELL="$HOME/.config/base16-shell/base16-eighties.dark.sh"
[[ -s $BASE16_SHELL ]] && source $BASE16_SHELL
# set vim as the default editor
export EDITOR=nvim
# vi mode
bindkey -v
bindkey jj vi-cmd-mode
# recover the readline keybindings
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
bindkey "^R" history-incremental-search-backward
bindkey "^P" history-search-backward
bindkey "^N" history-search-forward
bindkey "^F" forward-char
bindkey "^B" backward-char
# ls aliases
alias l='ls'
alias la='ls -la'
alias lah='ls -lah'
# git undo last commit alias
alias git-undo="git reset --soft 'HEAD^'"
# git difftool aliases
alias gdt='git difftool'
alias gdtc='git difftool --cached'
# git alias to sort branches by recently updated
alias gbs='git for-each-ref --sort=committerdate refs/heads/ \
--format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))"'
# git add from pattern using ag
function ag-git-add() {
ag --nocolor --null --files-with-matches "$*" | xargs -0 git add
}
alias aga=ag-git-add
function git-heroku-commit() {
git ls-remote $1 | awk 'END{print $1}' | xargs git show
}
alias ghc=git-heroku-commit
# Change less to ignore case, show colors, and improve the prompt
export LESS='-iR-P%f (%i/%m) Line %lt/%L'
# reload .zshrc
alias reload!='. ~/.zshrc'
# take me to my git home
alias git-home='cd "$(find-git-home)"'
# find git home directory
function find-git-home() {
git rev-parse --show-toplevel
}
# find the filename of the last migration based on file timestamp
function last-migration() {
ls -rt `find "$(find-git-home)/db/migrate" -type f -name "*" -print` | tail -1
}
alias vlmg='vim "$(last-migration)"'
function heroku-database-credentials() {
heroku pg:credentials $1 --app $2 | tail -n 1 | tr -d ' '
}
function heroku-pgcli() {
pgcli $(heroku-database-credentials $1 $2)
}
alias hpg=heroku-pgcli
alias vim=nvim
alias gdc='git diff --cached'
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh