-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzshrc
More file actions
126 lines (105 loc) · 4.39 KB
/
zshrc
File metadata and controls
126 lines (105 loc) · 4.39 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
120
121
122
123
124
125
# Lang
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Git prompt support
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto verbose"
source ~/.dotfiles/git-prompt.sh
setopt PROMPT_SUBST
# Load colors
autoload -U colors && colors
export PS1="%{$fg[yellow]%}%n@%m %{$fg[blue]%}%(8~|.../%7~|%~) %{$fg[red]%}%(?..{%?} )%{$fg[green]%}"'$(__git_ps1 "[%s]")'$'\n'"%{$fg[blue]%}» %{$reset_color%}"
# Set word boundaries for back/forward words
export WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
# I use Vim
hash vim >/dev/null 2>&1 && export EDITOR='vim'
# Set some options
setopt AUTOCD # Automatically change to typed directories
setopt AUTOPUSHD # Add directory changes to stack automatically
setopt NOCLOBBER # Prevent redirecting to existing files without >!
setopt INTERACTIVECOMMENTS # Allow comments in interactive command entry
# Reset Ctrl+A, Ctrl+E
bindkey -e
# Make forward delete work
bindkey "^[[3~" delete-char
bindkey "^[[3;5~" delete-char
# Configure completion
autoload -Uz compinit
compinit
fpath=( ~/.zsh/completion $fpath )
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' menu select
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/completion-cache
# Generic aliases
alias l="ls"
alias ll="ls -l"
alias la="ls -al"
alias less="less -R"
alias servehere="python3 -m http.server"
alias killtabs="sed -i 's/ / /g'"
alias sshonce="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
alias tailf="tail -F"
# This fixes bracketed paste problems (~00xxx01~) caused by a process turning on
# bracketed paste and then terminating before cleaning up after itself.
alias fixpaste='printf "\e[?2004l"'
function mkcd {
mkdir -p "$*"
cd "$*"
}
function hr {
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
}
# Make less better
if which pygmentize >/dev/null; then
export LESSOPEN="|pygmentize -g %s 2>/dev/null"
alias lessyn="/usr/bin/less -R"
alias less="less -L"
fi
# Configure history
export HISTORY_IGNORE="(fg|bg|history|cd|pwd|exit)"
export HISTSIZE=1000000
export SAVEHIST=$HISTSIZE
setopt HIST_IGNORE_ALL_DUPS # Don't record duplicates
setopt HIST_IGNORE_SPACE # Dont' record commands preceded with a space
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
unsetopt SHARE_HISTORY # Don't share history between sessions
setopt HIST_REDUCE_BLANKS # Remove unnecessary blanks before saving
HISTFILE=~/.zsh_history
case `uname` in
"Darwin")
alias ls="ls -OGh" # Show file flags, colorized output and human file sizes
alias catplist="plutil -convert xml1 -o -" # cat a plist even if it's binary
alias xcopen="X=\$(pwd); while [[ "\${X}" != "/" ]]; do PROJ=\$(find \${X} -name '*.xcworkspace' -maxdepth 1 -prune -print -quit); [[ -z \${PROJ} ]] && PROJ=\$(find \${X} -name '*.xcodeproj' -maxdepth 1 -prune -print -quit); if [[ -n \${PROJ} ]]; then open \${PROJ}; break; fi; X=\$(dirname \${X}); done"
alias lsregister="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"
alias cloudlogin="gcloud auth login --update-adc && aws sso login"
export HOSTNAME=$(scutil --get ComputerName) # The normal hostname is often useless
;;
"Linux")
alias ls="ls --color -h" # Show colorized output and human file sizes
alias ps="ps f" # Show processes as an ASCII tree
export HOSTNAME=$(echo $HOSTNAME | cut -d . -f 1)
[[ -e "${HOME}/.ls_colors" ]] && source ${HOME}/.ls_colors
;;
esac
# Add color to manpages
function man() {
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
/usr/bin/man "$@"
}
# Load Homebrew
if [[ -e "/opt/homebrew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
FPATH=$FPATH:/opt/homebrew/share/zsh/site-functions
compinit
fi
# If a local customization file exists, use it..
[[ -e "${HOME}/.zshrc.local" ]] && source ${HOME}/.zshrc.local