Skip to content

Commit 8c848a5

Browse files
author
Kamontat Chantrachirathumrong
committed
[feature] Add more features
1 parent 2a01765 commit 8c848a5

11 files changed

+140
-109
lines changed

.zshrc

+37-92
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,36 @@ source "${MYZS_LIB}/progress.sh"
2626
pg_start
2727
source "${MYZS_LIB}/lazyload.sh"
2828

29-
pg_mark "Load require libraries"
29+
pg_mark "Fetches required library"
3030
source "${MYZS_LIB}/setup.sh" || pg_mark_false "Loading setup file"
3131

3232
pg_mark "Setup variables"
3333
source "${MYZS_SRC}/custom.variable.sh" || pg_mark_false "Setting custom variable"
3434

35-
pg_mark "Setup alias"
36-
source "${MYZS_SRC}/default.alias.sh" || pg_mark_false "Loading default alias"
37-
source "${MYZS_SRC}/custom.alias.sh" || pg_mark_false "Loading custom alias"
38-
39-
pg_mark "Setup libraries"
40-
source "${MYZS_SRC}/default.library.sh" || pg_mark_false "Loading default library"
41-
42-
pg_mark "Setup completions"
43-
source "${MYZS_SRC}/default.completion.sh" || pg_mark_false "Loading default completion"
44-
45-
pg_mark "Setup work location"
46-
source "${MYZS_SRC}/location.sh" || pg_mark_false "Loading location cli"
47-
4835
pg_mark "Setup zgen"
4936
if is_string_exist "$ZGEN_HOME" && is_file_exist "${ZGEN_HOME}/zgen.zsh"; then
50-
source "${MYZS_SRC}/zgen.zsh"
37+
source "${MYZS_SRC}/default.zgen.plugin.zsh"
5138
source "${ZGEN_HOME}/zgen.zsh"
5239

5340
if ! zgen saved || $ZGEN_FORCE_SAVE; then
5441
# prezto options
55-
zgen prezto editor key-bindings 'emacs'
56-
zgen prezto prompt theme 'steeef'
42+
zgen prezto editor key-bindings 'vi'
43+
zgen prezto editor 'dot-expansion' 'yes'
44+
45+
# zgen prezto prompt theme 'spaceship'
46+
47+
zgen prezto autosuggestions color 'yes'
48+
zgen prezto 'autosuggestions:color' found 'fg=8'
49+
50+
# zgen prezto 'tmux:iterm' integrate 'yes'
51+
52+
zgen prezto terminal 'auto-title' 'yes'
53+
zgen prezto 'terminal:window-title' format '%n@%m: %s'
54+
zgen prezto 'terminal:tab-title' format '%m: %s'
55+
zgen prezto 'terminal:multiplexer-title' format '%s'
56+
57+
zgen prezto 'syntax-highlighting' color 'yes'
58+
zgen prezto 'syntax-highlighting' highlighters 'main' 'brackets' 'pattern' 'line' 'cursor' 'root'
5759

5860
zgen prezto
5961

@@ -65,6 +67,8 @@ if is_string_exist "$ZGEN_HOME" && is_file_exist "${ZGEN_HOME}/zgen.zsh"; then
6567
zgen load "$plugin"
6668
done
6769

70+
# zgen load denysdovhan/spaceship-prompt
71+
6872
# generate the init script from plugins above
6973
zgen save
7074
fi
@@ -75,85 +79,26 @@ else
7579
pg_mark_false "Zgen not found"
7680
fi
7781

78-
pg_stop
79-
80-
# SECONDS=0
81-
82-
# export MYZS_ROOT="${HOME}/.myzs"
83-
# export MYZS_SRC="${HOME}/.myzs/src"
84-
85-
# export MYZS_GLOBAL="${MYZS_ROOT}/global"
82+
pg_mark "Customize zgen plugin"
83+
source "${MYZS_SRC}/custom.zgen.plugin.zsh"
8684

87-
# export MYZS_SETTING="${MYZS_GLOBAL}/settings"
88-
# export MYZS_LIB="${MYZS_GLOBAL}/lib"
89-
90-
# export MYZS_CUSTOM="${MYZS_ROOT}/custom.lib"
91-
92-
# export MYZS_TEMP_FOLDER="/tmp/myzs"
93-
# mkdir $MYZS_TEMP_FOLDER &>/dev/null
94-
95-
# _myzs_is_integer() {
96-
# [[ $1 =~ ^[0-9]+$ ]] 2>/dev/null && return 0 || return 1
97-
# }
98-
99-
# throw() {
100-
# printf '%s\n' "$1" >&2 && _myzs_is_integer "$2" && return "$2"
101-
# return 0
102-
# }
103-
104-
# _myzs__load() {
105-
# local file="$1" # temp
106-
107-
# ! [ -f "$file" ] && _myzs_print_error_tofile "status" "file" "${file} NOT EXIST!"
108-
109-
# if source "$file"; then
110-
# _myzs_print_log_tostd "load" "file" "${file}"
111-
# return 0
112-
# else
113-
# _myzs_print_error_tostd "load" "file" "${file} (code=$?)"
114-
# return 1
115-
# fi
116-
# }
117-
118-
# _myzs_loop_load() {
119-
# local exit_code=0
120-
# for f in $1/[0-9]*; do
121-
# _myzs__load "$f" || ((exit_code++))
122-
# done
123-
124-
# return $exit_code
125-
# }
126-
127-
# _myzs_load() {
128-
# local folder="$1"
129-
# ! test -d "$folder" && throw "$folder Not EXIST!" && return 5
130-
# _myzs_loop_load "$folder"
131-
# }
132-
133-
# _myzs_raw_load() {
134-
# local folder="$1"
135-
# ! test -d "$folder" && echo "CANNOT load $folder" && return 199
136-
# _myzs_loop_load "$folder"
137-
# }
138-
139-
# _myzs_raw_load "$MYZS_LIB"
85+
pg_mark "Setup alias"
86+
source "${MYZS_SRC}/default.alias.sh" || pg_mark_false "Loading default alias"
87+
source "${MYZS_SRC}/custom.alias.sh" || pg_mark_false "Loading custom alias"
14088

141-
# _myzs_print_log_seperate_tostd "setting"
142-
# _myzs_raw_load "$MYZS_SETTING"
89+
pg_mark "Setup libraries"
90+
source "${MYZS_SRC}/default.library.sh" || pg_mark_false "Loading default library"
14391

144-
# _myzs_print_log_seperate_tostd "global"
145-
# _myzs_load "$MYZS_GLOBAL"
92+
pg_mark "Setup completions"
93+
source "${MYZS_SRC}/default.completion.sh" || pg_mark_false "Loading default completion"
14694

147-
# _myzs_print_log_seperate_tostd "custom"
148-
# _myzs_load "$MYZS_CUSTOM"
95+
pg_mark "Setup work location"
96+
source "${MYZS_SRC}/location.sh" || pg_mark_false "Loading location cli"
14997

150-
# _myzs_print_log_seperate_tostd "main"
151-
# _myzs_load "$MYZS_SRC"
98+
pg_mark "Setup prompt theme"
99+
source "${MYZS_SRC}/theme.sh" || pg_mark_false "Loading theme configuration"
152100

153-
# duration=$SECONDS
154-
# min="$((duration / 60))"
155-
# sec="$((duration % 60))"
101+
pg_mark "Customize Zsh setting"
102+
source "${MYZS_SRC}/custom.setting.zsh" || pg_mark_false "Setting zsh setting"
156103

157-
# _myzs_print_log_seperate_tostd
158-
# _myzs_print_log_tostd "status" "time" "$min minutes $sec seconds elapsed"
159-
# _myzs_print_log_tofile "status" "time" "$min minutes $sec seconds elapsed"
104+
pg_stop

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@
55
1. [prezto](https://github.com/sorin-ionescu/prezto) => Instantly Awesome Zsh
66
2. [powerlevel9k](https://github.com/bhilburn/powerlevel9k) => A theme for ZSH
77
3. [zgen](https://github.com/tarjoilija/zgen) => A lightweight plugin manager for Zsh
8+
9+
## Usage
10+
11+
1. Change your config in [constants.sh](./lib/constrants.sh)
12+
2. Change your setting in [variable.sh](./src/custom.variable.sh)

lib/setup.sh

-8
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,3 @@
44
if is_command_exist "git" && ! is_folder_exist "${HOME}/.zgen"; then
55
git clone "https://github.com/tarjoilija/zgen.git" "${HOME}/.zgen" &>/dev/null
66
fi
7-
8-
wd_name="${HOME}/.zgen/mfaerevaag/wd-master"
9-
if is_command_exist "git" && ! is_folder_exist "$wd_name"; then
10-
mkdir "$wd_name" &>/dev/null
11-
git clone "https://github.com/mfaerevaag/wd.git" "$wd_name" &>/dev/null
12-
13-
cp "${wd_name}/wd.1" "/usr/share/man/man1/wd.1"
14-
fi

src/custom.setting.zsh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# shellcheck disable=SC1090,SC2148
2+
3+
unsetopt correct_all
4+
unsetopt correct

src/custom.variable.sh

+2
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ export EDITOR='code-insiders'
1111

1212
export KEYTIMEOUT=1
1313

14+
export GOPATH="$HOME/Desktop/Projects/go"
15+
1416
set -o vi

src/custom.zgen.plugin.zsh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# shellcheck disable=SC1090,SC2148
2+
3+
wd_name="${HOME}/.zgen/mfaerevaag/wd-master"
4+
if is_command_exist "git" && ! is_folder_exist "$wd_name"; then
5+
mkdir "$wd_name" &>/dev/null
6+
git clone "https://github.com/mfaerevaag/wd.git" "$wd_name" &>/dev/null
7+
8+
cp "${wd_name}/wd.1" "/usr/share/man/man1/wd.1"
9+
fi
10+
11+
# contrib="${HOME}/.zgen/sorin-ionescu/prezto-master/contrib"
12+
# if ! is_folder_exist "$contrib"; then
13+
# git clone https://github.com/belak/prezto-contrib "$contrib"
14+
# cd contrib || exit 1
15+
# git submodule init
16+
# git submodule update
17+
# fi
18+
19+
spaceship_url="https://github.com/denysdovhan/spaceship-prompt.git"
20+
spaceship_location="${HOME}/.zgen/sorin-ionescu/prezto-master/modules/prompt/external/spaceship"
21+
22+
if ! is_folder_exist "$spaceship_location"; then
23+
git clone "$spaceship_url" "$spaceship_location" &>/dev/null
24+
ln -s "${spaceship_location}/spaceship.zsh-theme" ~/.zprezto/modules/prompt/functions/prompt_spaceship_setup
25+
fi
26+
27+
if is_file_exist "${spaceship_location}/spaceship.zsh-theme"; then
28+
prompt spaceship
29+
fi

src/default.alias.sh

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fi
7777

7878
if is_command_exist "code" || is_command_exist "code-insiders"; then
7979
alias newcode='code --new-window'
80+
alias ncode='code --new-window'
8081
alias ccode='code --reuse-window'
8182
fi
8283

src/default.completion.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# shellcheck disable=SC1090,SC2148
22

3-
if is_command_exist "kubectl"; then
4-
source <(kubectl completion zsh)
5-
fi
6-
73
gcloud_path='/usr/local/etc/google-cloud-sdk/path.zsh.inc'
84
if is_file_exist "$gcloud_path"; then
95
source "$gcloud_path"
@@ -14,6 +10,14 @@ if is_file_exist "$gcloud_completion"; then
1410
source "$gcloud_completion"
1511
fi
1612

13+
if is_command_exist "kubectl"; then
14+
source <(kubectl completion zsh)
15+
fi
16+
1717
if is_file_exist "$GO_ZSH_COMPLETE" || is_folder_exist "$GO_ZSH_COMPLETE"; then
1818
fpath=("${fpath[@]}" "$GO_ZSH_COMPLETE")
1919
fi
20+
21+
if is_string_exist "$ZGEN_DIR"; then
22+
fpath=("${fpath[@]}" "$ZGEN_DIR")
23+
fi

src/default.variable.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ if is_folder_exist "$HOME/Library/Android/sdk"; then
5959
export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" # android path
6060
fi
6161

62-
if is_command_exist "go" && is_folder_exist "$HOME/Documents/go"; then
63-
export GOPATH="$HOME/Documents/go"
62+
if is_command_exist "go"; then
6463
export PATH="$PATH:$GOPATH/bin" # go lang
65-
6664
export GO_ZSH_COMPLETE="$GOPATH/src/github.com/urfave/cli/autocomplete/zsh_autocomplete"
6765
fi
6866

src/zgen.zsh renamed to src/default.zgen.plugin.zsh

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
export ZGEN_FORCE_SAVE=false
44

5-
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=246'
65
export ZGEN_RESET_ON_CHANGE=("${HOME}/.zshrc")
76

87
# https://github.com/hlissner/zsh-autopair#zgen--prezto-compatibility
98
export AUTOPAIR_INHIBIT_INIT=1
109

1110
export ZGEN_PREZTO_PLUGIN_LIST=(
11+
# "contrib-prompt"
12+
"syntax-highlighting"
1213
"environment"
1314
"gnu-utility"
1415
"autosuggestions"
@@ -21,6 +22,8 @@ export ZGEN_PREZTO_PLUGIN_LIST=(
2122
"homebrew"
2223
"osx"
2324
"utility"
25+
"completion"
26+
"prompt"
2427
)
2528

2629
export ZGEN_PLUGIN_LIST=(
@@ -29,7 +32,6 @@ export ZGEN_PLUGIN_LIST=(
2932
"djui/alias-tips"
3033
"supercrabtree/k"
3134
"unixorn/autoupdate-zgen"
32-
"zsh-users/zsh-syntax-highlighting"
3335
"wbingli/zsh-wakatime"
3436
"hlissner/zsh-autopair"
3537
)

src/theme.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# shellcheck disable=SC1090,SC2148
2+
3+
# init promt theme
4+
5+
SPACESHIP_PROMPT_ORDER=(
6+
time
7+
user
8+
host
9+
hg
10+
package
11+
node
12+
ruby
13+
elixir
14+
xcode
15+
swift
16+
golang
17+
php
18+
rust
19+
julia
20+
docker
21+
aws
22+
venv
23+
conda
24+
pyenv
25+
dotnet
26+
ember
27+
line_sep
28+
dir
29+
git
30+
exec_time
31+
line_sep
32+
battery
33+
exit_code
34+
char
35+
)
36+
37+
SPACESHIP_RPROMPT_ORDER=(
38+
jobs
39+
)
40+
41+
SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true
42+
43+
SPACESHIP_TIME_SHOW=true
44+
SPACESHIP_TIME_FORMAT="%D{%d-%m-%Y %H.%M.%S}"
45+
SPACESHIP_BATTERY_SHOW=always
46+
47+
SPACESHIP_EXIT_CODE_SHOW=true
48+
SPACESHIP_EXEC_TIME_SHOW=true
49+
SPACESHIP_EXEC_TIME_ELAPSED=1

0 commit comments

Comments
 (0)