zshify 1.0.50 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/prompt.zsh +1 -119
- package/package.json +1 -1
package/bin/prompt.zsh
CHANGED
|
@@ -1,120 +1,2 @@
|
|
|
1
1
|
#!/bin/zsh
|
|
2
|
-
|
|
3
|
-
cat >~/.zshrc <<ZSHRC
|
|
4
|
-
HISTFILE=~/.zsh_history
|
|
5
|
-
HISTSIZE=5000
|
|
6
|
-
SAVEHIST=5000
|
|
7
|
-
|
|
8
|
-
setopt EXTENDED_HISTORY
|
|
9
|
-
setopt HIST_FIND_NO_DUPS
|
|
10
|
-
setopt HIST_IGNORE_ALL_DUPS
|
|
11
|
-
setopt INC_APPEND_HISTORY_TIME
|
|
12
|
-
setopt RM_STAR_SILENT
|
|
13
|
-
|
|
14
|
-
preexec() {
|
|
15
|
-
TIMER=$(print -P %D{%s%3.})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
precmd() {
|
|
19
|
-
CURRENT_BRANCH=$(git branch --show-current 2>/dev/null)
|
|
20
|
-
NEWLINE=$'\n'
|
|
21
|
-
PROMPT="$newline%F{cyan}%~ %F{white}$CURRENT_BRANCH$NEWLINE%(?.%F{green}.%F{red})%B%(!.#.>)%b%f "
|
|
22
|
-
newline=$NEWLINE
|
|
23
|
-
if [ $TIMER ]; then
|
|
24
|
-
NOW=$(print -P %D{%s%3.})
|
|
25
|
-
local diff=$(($NOW - $TIMER))
|
|
26
|
-
local ms=$((diff % 1000))
|
|
27
|
-
local s=$(((diff / 1000) % 60))
|
|
28
|
-
local m=$(((diff / 1000) / 60))
|
|
29
|
-
if ((m > 0)); then
|
|
30
|
-
local ELAPSED="${m}m ${s}s"
|
|
31
|
-
else
|
|
32
|
-
local ELAPSED="${s}.${ms}s"
|
|
33
|
-
fi
|
|
34
|
-
RPROMPT="%(?.%F{green}.%F{red})${ELAPSED}%f"
|
|
35
|
-
fi
|
|
36
|
-
unset TIMER
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
# aliases
|
|
40
|
-
alias zshrc='code ~/.zshrc'
|
|
41
|
-
|
|
42
|
-
# make and change to directory
|
|
43
|
-
cdx() {
|
|
44
|
-
mkdir -p $1 && cd $1
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
# better listing
|
|
48
|
-
lsx() {
|
|
49
|
-
tree --filesfirst -aCL 1 | sed -e 's/├── //g' -e 's/└── //g' | tail -n +2
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
# create github repository, pass --private to create private repository
|
|
53
|
-
mkrepo() {
|
|
54
|
-
command git init
|
|
55
|
-
command git add -A 2>/dev/null
|
|
56
|
-
command git commit -m "$(date)" 2>/dev/null
|
|
57
|
-
|
|
58
|
-
if [[ "$#" == "0" ]]; then
|
|
59
|
-
command gh repo create $(basename $(pwd)) -d '' --push -s . --public
|
|
60
|
-
else
|
|
61
|
-
command gh repo create $(basename $(pwd)) -d '' --push -s . "$@"
|
|
62
|
-
fi
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
# git add & git commit at once | git push
|
|
66
|
-
@git() {
|
|
67
|
-
if [[ "$#" == "0" ]]; then
|
|
68
|
-
command git add -A 2>/dev/null
|
|
69
|
-
command git commit -m "$(date)" 2>/dev/null
|
|
70
|
-
command git push
|
|
71
|
-
elif [[ "$#" == "1" ]]; then
|
|
72
|
-
command git add -A 2>/dev/null
|
|
73
|
-
command git commit -m "$1" 2>/dev/null
|
|
74
|
-
command git push
|
|
75
|
-
fi
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
# manage npm packages using yarn (just add @ in front of npm)
|
|
79
|
-
@npm() {
|
|
80
|
-
if [[ "$1" == "install" ]]; then
|
|
81
|
-
command yarn add ${@:2}
|
|
82
|
-
elif [[ "$1" == "uninstall" ]]; then
|
|
83
|
-
command yarn remove ${@:2}
|
|
84
|
-
fi
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
# kill pid by port
|
|
88
|
-
close() {
|
|
89
|
-
lsof -i :$1 | awk '{print $2}' | tail +2 | xargs kill -9
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
# rename current working dir or an existing folder
|
|
93
|
-
rename() {
|
|
94
|
-
if [[ "$#" == "1" ]]; then
|
|
95
|
-
command [ ! -d "../$1/" ] && rsync -a "$(pwd)/" "../$1" && rm -rf "$(pwd)/" && cd "../$1/"
|
|
96
|
-
if [[ $? == 0 && "$TERM_PROGRAM" == "vscode" ]]; then
|
|
97
|
-
code -r .
|
|
98
|
-
fi
|
|
99
|
-
elif [[ "$#" == "2" ]]; then
|
|
100
|
-
command [ ! -d "$2/" ] && rsync -a "$1/" "$2" && rm -rf "$1/"
|
|
101
|
-
else
|
|
102
|
-
command echo "Usage:"
|
|
103
|
-
command echo " rename new_dirname ~ renames current working dir"
|
|
104
|
-
command echo " rename dirname new_dirname ~ renames existing dir to new"
|
|
105
|
-
fi
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
|
109
|
-
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="bg=#000000,fg=#333333"
|
|
110
|
-
|
|
111
|
-
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
112
|
-
|
|
113
|
-
source /opt/homebrew/share/zsh-history-substring-search/zsh-history-substring-search.zsh
|
|
114
|
-
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="fg=green,bold,underline"
|
|
115
|
-
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND="fg=red,bold,underline"
|
|
116
|
-
bindkey '^[[A' history-substring-search-up
|
|
117
|
-
bindkey '^[[B' history-substring-search-down
|
|
118
|
-
|
|
119
|
-
echo "Hello"
|
|
120
|
-
ZSHRC
|
|
2
|
+
curl -s https://raw.githubusercontent.com/nrjdalal/mac-setup/main/.zshrc | cat >~/.zshrc
|