-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zsh_matt
More file actions
164 lines (146 loc) · 5.68 KB
/
Copy path.zsh_matt
File metadata and controls
164 lines (146 loc) · 5.68 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
### Antigen -- plugin management
# ============================================================
# See: https://github.com/zsh-users/antigen
# Install: `mkdir -p ~/.antigen; curl -L git.io/antigen > ~/.antigen/antigen.zsh`
source ~/.antigen/antigen.zsh # put this at top
antigen use oh-my-zsh # use Oh-My-Zsh plugins when applicable
# See ~/.antigen/bundles/
antigen_plugins=(
command-not-found # suggests packages on fail
# git # many git aliases
# git-prompt # git info in prompt w/ $git_super_status
pip # pip completion
supercrabtree/k # `k` improved ls -l
z # `z` jump to frequently used files
zsh-users/zsh-completions # extra completions
zsh-users/zsh-autosuggestions # suggestions for failed commands
zsh-users/zsh-syntax-highlighting # fish-like color changes; MUST BE LAST
)
# Define function to determine if a plugin exists
function isplugin() { if (($antigen_plugins[(Ie)$1])); then return 0; else return -1; fi; }
# Process Antigen plugins
for plugin in ${antigen_plugins[@]}; do
antigen bundle $plugin
done
antigen apply # apply antigen settings
# ============================================================
### Oh-My-Zsh -- helpful commands and plugins
# ============================================================
# * Cheatsheet: https://github.com/ohmyzsh/ohmyzsh/wiki/Cheatsheet
export ZSH="$HOME/.antigen/bundles/robbyrussell/oh-my-zsh/" # install location
## ---- OMZ Prompt Theme ----
# See ~/.antigen/bundles/robbyrussell/oh-my-zsh/themes/
# ZSH_THEME_RANDOM_CANDIDATES=( 'gnzh' 'bira' 'intheloop' 'tjkirch' ) # long
# ZSH_THEME_RANDOM_CANDIDATES=( 'flazz' 'sunrise' 'miloshadzic' ) # short
source $ZSH/oh-my-zsh.sh # apply Oh-My-Zsh settings
# omz theme use gnzh # random, gnzh,
# # ============================================================
### Custom Prompt Theme (overrides above themes)
# ============================================================
# Supported colors: red, blue, green, cyan, yellow, magenta, black, & white
timecolor="%B%F{black}"
usercolor="%b%F{magenta}"
pwdcolor="%b%F{blue}" # %B%F{blue} for actual dir color
arrowcolor="%b%F{black}"
othercolor="%B%F{magenta}"
# Git branch info
if (isplugin 'git-prompt'); then
git_branch='$(git_super_status)'
ZSH_THEME_GIT_PROMPT_PREFIX="‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="›%f"
else # if no git-prompt plugin
# git_branch='$(git_prompt_info)'
git_branch=''
fi
# User and hostname - change color if using SSH
function userhost_info() {
# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
echo "$othercolor%n%f$timecolor@$othercolor%M%f"
else
echo "$usercolor%n%f$timecolor@$usercolor%M%f"
fi
}
function prompt_matt_short() {
precmd(){} # printed before prompt
PROMPT="$pwdcolor%(5~|%-1~/…/%2~|%4~) $arrowcolor❯ " # ⇒➤»❯>
# Use git-prompt for git info if it is installed
if (isplugin 'git-prompt'); then
PROMPT="$git_branch $PROMPT"
fi
# Only display user info when SSHed into another machine
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PROMPT="$(userhost_info) $PROMPT"
fi
RPROMPT="" # no RHS info, or uncomment other RPROMPT
}
function prompt_matt_long() {
setopt prompt_subst
precmd(){ } # { print; } # printed before prompt
local user_host=$(userhost_info)
local current_dir="$pwdcolor%~%f%b"
PROMPT="$arrowcolor╭─$user_host $current_dir $git_branch
$arrowcolor╰─➤ %f "
RPROMPT=""
}
# Set prompt
prompt_matt_short
# prompt_matt_long
### User Configuration
# ============================================================
# ---- Directory Colors ----
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi
## ---- History ----
setopt histignorealldups sharehistory # ignore duplicates
# Keep N lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=100 # how many commands are loaded from history file
SAVEHIST=100 # how many commands are saved to history file
HISTFILE=~/.zsh_history
alias hist='history -i' # show history datetime by default
## ---- Completions ----
autoload -Uz compinit && compinit
CASE_SENSITIVE='false' # use case-sensitive completion
COMPLETION_WAITING_DOTS='true' # ... when waiting for completion
# HYPHEN_INSENSITIVE='true' # case-sensitive off, _- interchangeable
ENABLE_CORRECTION='true' # enable command auto-correction
# setopt globdots # tab-complete dot files (annoying b/c ./ and ../)
setopt noautomenu # Bash-like tab completion
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}" # tab-complete colors
## ---- Command Line Editing ----
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
# Have ctrl-u behave the same as Bash, delete part of line
bindkey \^U backward-kill-line
## ---- Utility ----
# Mass renaming with z-move
autoload -U zmv # zmv 'foo(*)' 'bar$1'
alias mmv='noglob zmv -W' # intuitive mass substitution: mmv foo.* bar.*
# Bash-like behavior for bg and fg
bg() {
if [[ $# -eq 1 && $1 = - ]]; then
builtin bg %-
else
builtin bg %"$@"
fi
}
fg() {
if [[ $# -eq 1 && $1 = - ]]; then
builtin fg %-
else
builtin fg %"$@"
fi
}
# Quality of life aliases
if (isplugin z); then; else; # if z plugin is not set
alias z="zsh" # use z to call zsh
fi
# ============================================================
## Copy and uncomment the following to the bottom of ~/.zshrc
# autoload -Uz bashcompinit && bashcompinit
# export WHOME="/path/to/windows/home"
# source ~/.bash_local
# source ~/.bash_matt_private
# source ~/.bash_matt
# source ~/.zsh_matt