forked from driesvints/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zshrc
More file actions
193 lines (161 loc) · 4.09 KB
/
.zshrc
File metadata and controls
193 lines (161 loc) · 4.09 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
192
193
# dotfiles 경로
export DOTFILES=$HOME/.dotfiles
export ZSH="$HOME/.oh-my-zsh"
DEFAULT_USER="$USER"
ZSH_THEME="agnoster"
# Uncomment one of the following lines to change the auto-update behavior
zstyle ':omz:update' mode auto # update automatically without asking
# Uncomment the following line if you want to change the command execution time
HIST_STAMPS="yyyy-mm-dd"
# Would you like to use another custom folder than $ZSH/custom?
ZSH_CUSTOM=$DOTFILES
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
plugins=(
git
docker
kubectl
z
direnv
zsh-completions #1
zsh-autosuggestions #2
zsh-syntax-highlighting #3
alias-tips #4
)
source $ZSH/oh-my-zsh.sh
# Locale 설정
export LC_ALL=ko_KR.UTF-8
export LANG=ko_KR.UTF-8
# History 설정
HISTTIMEFORMAT="[%d.%m.%y] %T "
export HISTSIZE=10000
export HISTTIMEFORMAT
# Git Username/Email 설정
git config --global user.name "taking"
git config --global user.email "taking@duck.com"
# Git Logs 설정
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.lga "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
# Git Delta 설정
git config --global core.pager "delta"
git config --global interactive.diffFilter "delta --color-only"
git config --global merge.conflitstyle "diff3"
git config --global diff.colorMoved "default"
git config --global delta.navigate true
git config --global delta.line-numbers true
git config --global delta.side-by-side true
# home / end 키 설정
case $TERM in (xterm*)
bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line
esac
mkcd () {
if [ $# -ne 1 ]; then
echo 'usage: mkcd <dir-name>'
return 137
fi
# 폴더 생성 후 폴더로 진입
local dir_name="$1"
mkdir -p "$dir_name" && cd "$dir_name"
}
extract () {
if [ $# -ne 1 ] ; then
echo 'usage: extract <file-name>'
return 137
fi
# 암축 형식의 확장자를 찾아 압축 해제
case $1 in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "cannot extract: $1" ;;
esac
}
tree() {
local depth=2
local dir="."
while [[ $# -gt 0 ]]; do
case "$1" in
-L)
depth="$2"
shift 2
;;
*)
dir="$1"
shift
;;
esac
done
lsd --tree \
--depth "$depth" \
--group-dirs first \
"$dir"
# -a \
# --icon always \
}
up() {
local n="${1:-1}"
local target=""
if ! [[ "$n" =~ ^[0-9]+$ ]]; then
echo "usage: up [number]"
return 1
fi
for ((i=0; i<n; i++)); do
target+="../"
done
cd "$target"
}
fcd() {
local dir
dir=$(
command find . -type d 2>/dev/null \
| sed 's#^\./##' \
| grep -v '^\.$' \
| fzf --height 40% --reverse --prompt='cd> '
) || return
if [[ -z "$dir" ]]; then
echo "No directories found."
return 1
fi
cd "$dir"
}
ff() {
local file
file=$(
command find . -type f 2>/dev/null \
| sed 's#^\./##' \
| fzf --height 40% --reverse --prompt='file> '
) || return
if [[ -z "$file" ]]; then
echo "No files found."
return 1
fi
echo "$file"
}
br() {
broot "${1:-.}"
}
# Update external zsh plugins
plugin-update() {
for d in $ZSH_CUSTOM/plugins/*/.git(/); do
echo "Updating ${d:h:t}..."
command git -C "${d:h}" pull --ff --recurse-submodules --depth 1 --rebase --autostash
done
}
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}