-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zshrc
More file actions
192 lines (161 loc) · 6.64 KB
/
.zshrc
File metadata and controls
192 lines (161 loc) · 6.64 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# ________ _______. __ __ .______ ______
# | / / || | | | | _ \ / |
# `---/ / | (----`| |__| | | |_) | | ,----'
# / / \ \ | __ | | / | |
# __ / /----.----) | | | | | | |\ \----.| `----.
#(__)________|_______/ |__| |__| | _| `._____| \______|
#
################## Oh-my-zsh Section ##################################
# Path to your oh-my-zsh installation.
ZSH="$HOME/.oh-my-zsh"
if [ ! -d "$ZSH" ]; then
git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH/custom/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH/custom/plugins/zsh-autosuggestions
git clone https://github.com/zdharma/fast-syntax-highlighting.git $ZSH/custom/plugins/fast-syntax-highlighting
git clone https://github.com/zsh-users/zsh-completions $ZSH/custom/plugins/zsh-completions
git clone https://github.com/chisui/zsh-nix-shell.git $ZSH/custom/plugins/nix-shell
git clone https://github.com/spwhitt/nix-zsh-completions.git $ZSH/custom/plugins/nix-zsh-completions
fi
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(nix-shell nix-zsh-completions zsh-autosuggestions fast-syntax-highlighting zsh-completions colored-man-pages extract)
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
if [ -z "$DISPLAY" ]; then
ZSH_THEME="rkj-repos"
else
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block, everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
ZSH_THEME="powerlevel10k/powerlevel10k"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
fi
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
UPDATE_ZSH_DAYS=5
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="false"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
ZSH_CACHE_DIR=$HOME/.cache/oh-my-zsh
if [ ! -d $ZSH_CACHE_DIR ]; then
mkdir $ZSH_CACHE_DIR
fi
# Use autosuggestion
# https://github.com/zsh-users/zsh-autosuggestions
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
# Start oh-my-zsh
source $ZSH/oh-my-zsh.sh
###################### End of Oh-my-zsh section ##################################
#################### User settings below this line ################################
# Extended globbing. Allows using regular expressions with *
setopt extendedglob
# Case insensitive globbing
setopt nocaseglob
# Array expension with parameters
setopt rcexpandparam
# Dont warn about running processes when exiting
setopt nocheckjobs
# Sort filenames numerically when it makes sense
setopt numericglobsort
# No beep
setopt nobeep
# Immediately append history instead of overwriting
setopt appendhistory
# If a new command is a duplicate, remove the older one
setopt histignorealldups
# if only directory path is entered, cd there.
setopt autocd
# Remove command lines from the history list when the first character on the line is a space.
setopt HIST_IGNORE_SPACE
########################## Aliases section ########################################
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
alias ohmyzsh='nvim ~/.oh-my-zsh'
alias ls='exa --group-directories-first' # https://the.exa.website/
alias cp='cp -R'
alias rm='rm -Ivr'
alias :q='exit'
alias vim='nvim'
alias mocp='mocp -T darkdot_theme'
alias webcam='mpv /dev/video0'
alias .='cd ../'
alias ..='cd ../../'
####################### Custom functions ###############################
c() {
if [ $# -eq 0 ] ; then
clear
elif [ -d "$1" ] ; then
cd "$1"
elif [ -f "$1" ] ; then
cat "$1"
fi
}
# Ref: https://github.com/paulmillr/dotfiles/blob/master/home/.zshrc.sh#L282
# Show how much RAM application uses.
# $ ram safari
# # => safari uses 154.69 MBs of RAM.
ram() {
local sum
local items
local app="$1"
if [ -z "$app" ]; then
echo "First argument - pattern to grep from processes"
else
sum=0
for i in `ps aux | grep -i "$app" | grep -v "grep" | awk '{print $6}'`; do
sum=$(($i + $sum))
done
sum=$(echo "scale=2; $sum / 1024.0" | bc)
if [[ $sum != "0" ]]; then
echo "${fg[blue]}${app}${reset_color} uses ${fg[green]}${sum}${reset_color} MBs of RAM."
else
echo "There are no processes with pattern '${fg[blue]}${app}${reset_color}' are running."
fi
fi
}
clima() {
local cache="$HOME/.cache/clima"
local tmp="/tmp/clima"
if curl -s 'pt.wttr.in' > $tmp; then
mv $tmp $cache
cat $cache
elif [ -e $cache ]; then
echo "Without internet connection, using local cache."
cat $cache
else
echo "You need internet connection!"
fi
}
# Reload color settings of my logitech g512 keyboard
# and change keyboard layout
loadg512() {
g810-led -p /etc/g810-led/profile
setxkbmap -layout us -variant intl
}
###############################################################