-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zprofile
121 lines (102 loc) 路 3.9 KB
/
.zprofile
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
120
121
## ----------------------------------------------------------------------------
# CONFIGS
# -----------------------------------------------------------------------------
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export PS1=$'%B%n%b@%B%m%b:[%~]%(?.. (%?%))\n>> '
export EDITOR="vim"
export GPG_TTY=`tty`
bindkey -e # Fix Ctrl-A unbinding.
# Add brew to PATH
eval $(/opt/homebrew/bin/brew shellenv)
## ----------------------------------------------------------------------------
# HISTORY CONF
# -----------------------------------------------------------------------------
export HISTFILE="${HOME}/.zhistory"
export HISTSIZE=10000
export SAVEHIST=10000
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt APPEND_HISTORY
## ----------------------------------------------------------------------------
# ZSH GIT COMPLETION
# -----------------------------------------------------------------------------
autoload -U compinit && compinit
zmodload -i zsh/complist
## ----------------------------------------------------------------------------
# ALIASES
# -----------------------------------------------------------------------------
alias less="less -x4SRFX"
alias grep="grep --color=auto -I"
alias grep_search="grep -Eir " # extended regex, recursive, ignore case, show line number
# Git Alias to merge a branch from an approved PR
function gmerge() {
git co master && \
git rebase $1 && \
git push origin master && \
git br -d $1 && \
git push origin :$1
}
# Global aliases
alias -g H="| head"
alias -g T="| tail -f"
alias -g G="| grep"
alias -g C="| column -t"
alias -g L="| less"
alias -g M="| most"
alias -g WL="| wc -l"
alias -g RE="2>&1"
alias -g CA="| cat -A"
alias -g NULE="2> /dev/null"
alias -g NUL="> /dev/null"
alias -g P="2>&1 | pygmentize -l pytb"
alias -g S="sudo "
alias -g GS="grep_search "
alias -g PR="2>&1 | tee /dev/tty | grep -oE 'https://.*' | xargs open -a Google\ Chrome"
alias -g OP="AWS_ACCESS_KEY_ID=\"op://\$AWS_OP_PROFILE/AWS_ACCESS_KEY_ID\" AWS_SECRET_ACCESS_KEY=\"op://\$AWS_OP_PROFILE/AWS_SECRET_ACCESS_KEY\" op run --"
# Suffix aliases
alias -s md="vim"
alias -s conf="vim"
alias -s txt="vim"
alias -s jpg="open"
alias -s png="open"
alias -s pdf="open"
alias -s gif="open"
alias -s zip="unzip -l"
alias -s rar="unrar l"
alias -s tar="tar tf"
alias -s tar.gz="echo "
alias -s ace="unace l"
## ----------------------------------------------------------------------------
# Source Dependencies
# -----------------------------------------------------------------------------
# Google Cloud SDK
if [ -f /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc ]
then
. /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc
fi
# ~/.zenv
[ -f ~/.zenv ] && source ~/.zenv
# fzf for ZSH ~/.fzf.zsh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
## ----------------------------------------------------------------------------
# TMUX
# -----------------------------------------------------------------------------
if [ -z $TMUX ] # Check if we are already inside tmux
then
if tmux ls | grep --silent "main"
then
if tmux ls | grep -e "^main: .*" | grep --silent -v -e ".* (attached)$"
then
tmux attach-session -t main
fi
else
tmux new-session -s main
fi
fi