-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
119 lines (100 loc) · 2.72 KB
/
.zshrc
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
# Fig pre block. Keep at the top of this file.
. "$HOME/.fig/shell/zshrc.pre.zsh"
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="agnoster"
# zsh plugins
plugins=(
git
zsh-autosuggestions
zsh-z
)
eval "$(starship init zsh)"
source $ZSH/oh-my-zsh.sh
# git
function branch { git checkout -b $@}
function checkout { git checkout $@}
function commit { git add . && git commit -a -m $@ }
alias pull="git fetch && git pull"
alias push="git push"
alias status="git status"
alias master="git checkout master && pull"
alias main="git checkout main && pull"
alias gitreset="git reset --hard"
alias goback="git checkout -"
alias undocommit="git reset --soft HEAD~1"
alias undoLastcommit="git push -f origin HEAD^:master"
alias gh="open \`git remote -v | grep [email protected] | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
alias gitlog="git log --graph --all --decorate --oneline"
# directory
alias sites="cd ~/sites"
alias documents="cd ~/Documents"
alias downloads="cd ~/Downloads"
alias back="cd -"
alias sourcealias="source ~/.zshrc"
alias openalias="vim ~/.zshrc"
alias codealias="code ~/.zshrc"
# npm
alias t="npm t"
alias ni="npm i"
# auto nvm
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc
# common functions
function grephistory() {
history|grep $1
}
function cmpname() {
echo $(basename $(pwd))
}
function jen() {
echo "opening jenkins $(cmpname)"
open "" # <- REPLACE URL HERE
}
function awsdev() {
echo "opening tooling aws"
open "" # <- REPLACE URL HERE
}
function nls() {
echo npm ls $1
npm ls '\@ibl/$1'
}
function clone() {
git clone [email protected]:bbc/$1.git
cd $1
}
function go() {
sites
if [ -d "$1" ]; then
echo "Directory found \n"
echo "Now in: /sites/$1"
cd $1 && git pull
else
echo "cloning repo $1"
clone $1
fi
}
eval "$(starship init zsh)"
PATH="$HOME/sites/bashfiles/:$PATH"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
export GPG_TTY=$(tty)
# Fig post block. Keep at the bottom of this file.
. "$HOME/.fig/shell/zshrc.post.zsh"