run zshrc through shfmt, comment prompt line
This commit is contained in:
parent
4adde9d9f4
commit
427c7b3cf2
@ -8,10 +8,10 @@
|
|||||||
# ls and grep options
|
# ls and grep options
|
||||||
ls --version &>/dev/null
|
ls --version &>/dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
LS_OPTS="--color --group-directories-first -F"
|
LS_OPTS="--color --group-directories-first -F"
|
||||||
else
|
else
|
||||||
LS_OPTS="-GF"
|
LS_OPTS="-GF"
|
||||||
export CLICOLOR=1
|
export CLICOLOR=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export GREP_OPTS="--color=auto"
|
export GREP_OPTS="--color=auto"
|
||||||
@ -25,7 +25,7 @@ export HISTSIZE=999999999
|
|||||||
export SAVEHIST=$HISTSIZE
|
export SAVEHIST=$HISTSIZE
|
||||||
|
|
||||||
# * * * * * * * * *
|
# * * * * * * * * *
|
||||||
## Shell Options *
|
# Shell Options *
|
||||||
# * * * * * * * * *
|
# * * * * * * * * *
|
||||||
|
|
||||||
# Setting options
|
# Setting options
|
||||||
@ -36,7 +36,7 @@ setopt share_history
|
|||||||
setopt histsavenodups
|
setopt histsavenodups
|
||||||
setopt hist_ignore_all_dups
|
setopt hist_ignore_all_dups
|
||||||
setopt interactive_comments
|
setopt interactive_comments
|
||||||
setopt auto_menu # tab completion
|
setopt auto_menu # tab completion
|
||||||
setopt prompt_subst # command substitution in prompt
|
setopt prompt_subst # command substitution in prompt
|
||||||
unsetopt correct_all
|
unsetopt correct_all
|
||||||
autoload -Uz compinit && compinit
|
autoload -Uz compinit && compinit
|
||||||
@ -49,10 +49,10 @@ bindkey -e
|
|||||||
bindkey '\e[3~' delete-char
|
bindkey '\e[3~' delete-char
|
||||||
bindkey '^p' history-search-backward
|
bindkey '^p' history-search-backward
|
||||||
bindkey '^n' history-search-forward
|
bindkey '^n' history-search-forward
|
||||||
bindkey ' ' magic-space
|
bindkey ' ' magic-space
|
||||||
|
|
||||||
# * * * * * *
|
# * * * * * *
|
||||||
## Aliases *
|
# Aliases *
|
||||||
# * * * * * *
|
# * * * * * *
|
||||||
|
|
||||||
# core utils
|
# core utils
|
||||||
@ -72,13 +72,13 @@ alias pathls='printf "%b\n" "${PATH//:/\\n}"'
|
|||||||
|
|
||||||
# git - vim - tmux
|
# git - vim - tmux
|
||||||
alias g="git"
|
alias g="git"
|
||||||
alias groot="cd $(git rev-parse --show-toplevel 2> /dev/null || echo -n ".")"
|
alias groot="cd $(git rev-parse --show-toplevel 2>/dev/null || echo -n ".")"
|
||||||
alias v="$EDITOR"
|
alias v="$EDITOR"
|
||||||
alias vi="$EDITOR"
|
alias vi="$EDITOR"
|
||||||
alias tmls="tmux ls"
|
alias tmls="tmux ls"
|
||||||
alias tmlsc="tmux lsc"
|
alias tmlsc="tmux lsc"
|
||||||
alias tmks="tmux kill-session -t" # kill one session
|
alias tmks="tmux kill-session -t" # kill one session
|
||||||
alias tmka="tmux kill-server" # aka killall
|
alias tmka="tmux kill-server" # aka killall
|
||||||
|
|
||||||
# python
|
# python
|
||||||
alias py="python3"
|
alias py="python3"
|
||||||
@ -102,114 +102,109 @@ touchx() { touch "$@" && chmod +x "$@"; }
|
|||||||
|
|
||||||
# git
|
# git
|
||||||
lazygit() {
|
lazygit() {
|
||||||
git commit -a -m "$*" && git push;
|
git commit -a -m "$*" && git push
|
||||||
}
|
}
|
||||||
lg() {
|
lg() {
|
||||||
lazygit "$*";
|
lazygit "$*"
|
||||||
}
|
|
||||||
|
|
||||||
# vim
|
|
||||||
swp_vimrc(){
|
|
||||||
mv ~/.vim/vimrc ~/.vim/vimrc.swp
|
|
||||||
mv ~/.vim/vimrc.min ~/.vim/vimrc
|
|
||||||
mv ~/.vim/vimrc.swp ~/.vim/vimrc.min
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# tmux
|
# tmux
|
||||||
tm() {
|
tm() {
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
tmux new-session -As "$1"
|
tmux new-session -As "$1"
|
||||||
else
|
else
|
||||||
tmux new-session
|
tmux new-session
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
tma() {
|
tma() {
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
tmux attach-session -d -t "$1"
|
tmux attach-session -d -t "$1"
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
tmux new-session -As "$1"
|
tmux new-session -As "$1"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
tmux attach
|
tmux attach
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# misc functions
|
# misc functions
|
||||||
colordump(){
|
colordump() {
|
||||||
for i in $(seq 0 255); do printf "$(tput setaf $i)$i "; done
|
for i in $(seq 0 255); do printf "$(tput setaf $i)$i "; done
|
||||||
}
|
}
|
||||||
|
|
||||||
# "smart" extract function
|
# "smart" extract function
|
||||||
extract() {
|
extract() {
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
# display usage if no parameters given
|
# display usage if no parameters given
|
||||||
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
||||||
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
for n in "$@"; do
|
for n in "$@"; do
|
||||||
if [ -f "$n" ] ; then
|
if [ -f "$n" ]; then
|
||||||
case "${n%,}" in
|
case "${n%,}" in
|
||||||
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
|
*.tar.bz2 | *.tar.gz | *.tar.xz | *.tbz2 | *.tgz | *.txz | *.tar)
|
||||||
tar xvf "$n" ;;
|
tar xvf "$n"
|
||||||
*.lzma) unlzma ./"$n" ;;
|
;;
|
||||||
*.bz2) bunzip2 ./"$n" ;;
|
*.lzma) unlzma ./"$n" ;;
|
||||||
*.rar) unrar x -ad ./"$n" ;;
|
*.bz2) bunzip2 ./"$n" ;;
|
||||||
*.gz) gunzip ./"$n" ;;
|
*.rar) unrar x -ad ./"$n" ;;
|
||||||
*.zip) unzip ./"$n" ;;
|
*.gz) gunzip ./"$n" ;;
|
||||||
*.z) uncompress ./"$n" ;;
|
*.zip) unzip ./"$n" ;;
|
||||||
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
|
*.z) uncompress ./"$n" ;;
|
||||||
7z x ./"$n" ;;
|
*.7z | *.arj | *.cab | *.chm | *.deb | *.dmg | *.iso | *.lzh | *.msi | *.rpm | *.udf | *.wim | *.xar)
|
||||||
*.xz) unxz ./"$n" ;;
|
7z x ./"$n"
|
||||||
*.exe) cabextract ./"$n" ;;
|
;;
|
||||||
*)
|
*.xz) unxz ./"$n" ;;
|
||||||
echo "extract: '$n' - unknown archive method"
|
*.exe) cabextract ./"$n" ;;
|
||||||
return 1
|
*)
|
||||||
;;
|
echo "extract: '$n' - unknown archive method"
|
||||||
esac
|
return 1
|
||||||
else
|
;;
|
||||||
echo "'$n' - file does not exist"
|
esac
|
||||||
return 1
|
else
|
||||||
fi
|
echo "'$n' - file does not exist"
|
||||||
done
|
return 1
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bkup() {
|
bkup() {
|
||||||
if [ -f "$1" ]; then
|
if [ -f "$1" ]; then
|
||||||
cp "${1}" "${1}.bkup.$(date +'%F.%R')";
|
cp "${1}" "${1}.bkup.$(date +'%F.%R')"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
datauri() {
|
datauri() {
|
||||||
local mimeType=""
|
local mimeType=""
|
||||||
if [ -f "$1" ]; then
|
if [ -f "$1" ]; then
|
||||||
mimeType=$(file -b --mime-type "$1")
|
mimeType=$(file -b --mime-type "$1")
|
||||||
|
|
||||||
if [[ $mimeType == text/* ]]; then
|
if [[ $mimeType == text/* ]]; then
|
||||||
mimeType="$mimeType;charset=utf-8"
|
mimeType="$mimeType;charset=utf-8"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "data:%s;base64,%s" \
|
printf "data:%s;base64,%s" \
|
||||||
"$mimeType" \
|
"$mimeType" \
|
||||||
"$(openssl base64 -in "$1" | tr -d "\n")"
|
"$(openssl base64 -in "$1" | tr -d "\n")"
|
||||||
else
|
else
|
||||||
printf "%s is not a file.\n" "$1"
|
printf "%s is not a file.\n" "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# grep with color into less
|
# grep with color into less
|
||||||
grepless(){
|
grepless() {
|
||||||
grep -ir --color=always "$*" --exclude-dir=".git" --exclude-dir="node_modules" . | less -RX
|
grep -ir --color=always "$*" --exclude-dir=".git" --exclude-dir="node_modules" . | less -RX
|
||||||
}
|
}
|
||||||
|
|
||||||
# curl shortcuts
|
# curl shortcuts
|
||||||
cheatsh() {
|
cheatsh() {
|
||||||
curl cheat.sh/"$1"
|
curl cheat.sh/"$1"
|
||||||
}
|
}
|
||||||
watip() {
|
watip() {
|
||||||
curl ifconfig.co
|
curl ifconfig.co
|
||||||
# dig +short myip.opendns.com @resolver1.opendns.com
|
# dig +short myip.opendns.com @resolver1.opendns.com
|
||||||
}
|
}
|
||||||
|
|
||||||
# * * * * * * * * * * * *
|
# * * * * * * * * * * * *
|
||||||
@ -220,95 +215,94 @@ watip() {
|
|||||||
# PROMPT='%n@%m %~ %# '
|
# PROMPT='%n@%m %~ %# '
|
||||||
|
|
||||||
git_prompt() {
|
git_prompt() {
|
||||||
BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/*\(.*\)/\1/')
|
BRANCH=$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/*\(.*\)/\1/')
|
||||||
STATUS="$(git status 2> /dev/null)"
|
STATUS="$(git status 2>/dev/null)"
|
||||||
|
|
||||||
if [[ "$?" -ne 0 ]]; then
|
if [[ "$?" -ne 0 ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $BRANCH ]; then
|
if [ ! -z $BRANCH ]; then
|
||||||
printf "%s" "%F{reset}%F{yellow}$BRANCH"
|
printf "%s" "%F{reset}%F{yellow}$BRANCH"
|
||||||
printf "%s" "%F{reset}["
|
printf "%s" "%F{reset}["
|
||||||
if echo "${STATUS}" | grep -c "nothing to commit" &> /dev/null; then printf "%s" "%F{blue}="; fi
|
if echo "${STATUS}" | grep -c "nothing to commit" &>/dev/null; then printf "%s" "%F{blue}="; fi
|
||||||
if echo "${STATUS}" | grep -c "renamed:" &> /dev/null; then printf "%s" "%F{red}%"; fi
|
if echo "${STATUS}" | grep -c "renamed:" &>/dev/null; then printf "%s" "%F{red}%"; fi
|
||||||
if echo "${STATUS}" | grep -c "deleted:" &> /dev/null; then printf "%s" "%F{red}-"; fi
|
if echo "${STATUS}" | grep -c "deleted:" &>/dev/null; then printf "%s" "%F{red}-"; fi
|
||||||
if echo "${STATUS}" | grep -c "new file:" &> /dev/null; then printf "%s" "%F{green}+"; fi
|
if echo "${STATUS}" | grep -c "new file:" &>/dev/null; then printf "%s" "%F{green}+"; fi
|
||||||
if echo "${STATUS}" | grep -c "branch is ahead:" &> /dev/null; then printf "%s" "%F{yellow}>"; fi
|
if echo "${STATUS}" | grep -c "branch is ahead:" &>/dev/null; then printf "%s" "%F{yellow}>"; fi
|
||||||
if echo "${STATUS}" | grep -c "branch is behind" &> /dev/null; then printf "%s" "%F{yellow}<"; fi
|
if echo "${STATUS}" | grep -c "branch is behind" &>/dev/null; then printf "%s" "%F{yellow}<"; fi
|
||||||
if echo "${STATUS}" | grep -c "Untracked files:" &> /dev/null; then printf "%s" "%F{yellow}?"; fi
|
if echo "${STATUS}" | grep -c "Untracked files:" &>/dev/null; then printf "%s" "%F{yellow}?"; fi
|
||||||
if echo "${STATUS}" | grep -c "Changes not staged for commit:" &> /dev/null; then printf "%s" "%F{red}*"; fi
|
if echo "${STATUS}" | grep -c "Changes not staged for commit:" &>/dev/null; then printf "%s" "%F{red}*"; fi
|
||||||
if echo "${STATUS}" | grep -c "Changes to be committed:" &> /dev/null; then printf "%s" "%F{green}="; fi
|
if echo "${STATUS}" | grep -c "Changes to be committed:" &>/dev/null; then printf "%s" "%F{green}="; fi
|
||||||
printf "%s" "%F{reset}]"
|
printf "%s" "%F{reset}]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
PROMPT='%F{blue}%~$(git_prompt) %F{yellow}%# %F{reset}'
|
# PROMPT='%F{blue}%~$(git_prompt) %F{green}%# %F{reset}'
|
||||||
|
|
||||||
# * * * * * * * * * * * * * * * * * * *
|
# * * * * * * * * * * * * * * * * * * *
|
||||||
# Language Specific Version Managers *
|
# Language Specific Version Managers *
|
||||||
# * * * * * * * * * * * * * * * * * * *
|
# * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
# rbenv (ruby)
|
# rbenv (ruby)
|
||||||
src_rbenv(){
|
src_rbenv() {
|
||||||
if command -v ruby > /dev/null && command -v gem > /dev/null; then
|
if command -v ruby >/dev/null && command -v gem >/dev/null; then
|
||||||
path+=("$(ruby -r rubygems -e 'puts Gem.user_dir')/bin")
|
path+=("$(ruby -r rubygems -e 'puts Gem.user_dir')/bin")
|
||||||
# rbenv shim
|
# rbenv shim
|
||||||
if [ -d "$HOME/.rbenv/bin" ]; then
|
if [ -d "$HOME/.rbenv/bin" ]; then
|
||||||
path+=("$HOME/.rbenv/bin")
|
path+=("$HOME/.rbenv/bin")
|
||||||
[[ ":$PATH:" != *":$HOME/.rbenv/shims:"* ]] && eval "$(rbenv init - zsh)"
|
[[ ":$PATH:" != *":$HOME/.rbenv/shims:"* ]] && eval "$(rbenv init - zsh)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# nvm (node)
|
# nvm (node)
|
||||||
src_nvm(){
|
src_nvm() {
|
||||||
if [ -d "$HOME/.nvm" ]; then
|
if [ -d "$HOME/.nvm" ]; then
|
||||||
export NVM_DIR="$HOME/.nvm"
|
export NVM_DIR="$HOME/.nvm"
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# pyenv (python3)
|
# pyenv (python3)
|
||||||
src_pyenv() {
|
src_pyenv() {
|
||||||
if [ -d "$HOME/.pyenv" ]; then
|
if [ -d "$HOME/.pyenv" ]; then
|
||||||
export PYENV_ROOT="$HOME/.pyenv"
|
export PYENV_ROOT="$HOME/.pyenv"
|
||||||
path+=("$PYENV_ROOT/bin")
|
path+=("$PYENV_ROOT/bin")
|
||||||
command -v pyenv > /dev/null && eval "$(pyenv init -)"
|
command -v pyenv >/dev/null && eval "$(pyenv init -)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# go
|
# go
|
||||||
src_go() {
|
src_go() {
|
||||||
# move go path from ~/go to ~/.go (hidden)
|
# move go path from ~/go to ~/.go (hidden)
|
||||||
[ -d "$HOME/go" ] && mv "$HOME/go" "$HOME/.go"
|
[ -d "$HOME/go" ] && mv "$HOME/go" "$HOME/.go"
|
||||||
export GOPATH="$HOME/.go"
|
export GOPATH="$HOME/.go"
|
||||||
export GOWD="$GOPATH/src/github.com/lemonase"
|
export GOWD="$GOPATH/src/github.com/lemonase"
|
||||||
export GOMOD="$GOPATH/pkg/mod/github.com/lemonase/"
|
export GOMOD="$GOPATH/pkg/mod/github.com/lemonase/"
|
||||||
path+=("$(go env GOPATH)/bin")
|
path+=("$(go env GOPATH)/bin")
|
||||||
}
|
}
|
||||||
|
|
||||||
# rust/cargo
|
# rust/cargo
|
||||||
src_rust() {
|
src_rust() {
|
||||||
path+=("$HOME/.cargo/bin")
|
path+=("$HOME/.cargo/bin")
|
||||||
}
|
}
|
||||||
|
|
||||||
# ruby
|
# ruby
|
||||||
if command -v rbenv > /dev/null; then
|
if command -v rbenv >/dev/null; then
|
||||||
src_rbenv
|
src_rbenv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# go
|
# go
|
||||||
if command -v go > /dev/null; then
|
if command -v go >/dev/null; then
|
||||||
src_go
|
src_go
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# rust
|
# rust
|
||||||
if command -v cargo > /dev/null; then
|
if command -v cargo >/dev/null; then
|
||||||
src_rust
|
src_rust
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# * * * * * * * * * * * *
|
# * * * * * * * * * * * *
|
||||||
# MISC $PATH Additions *
|
# MISC $PATH Additions *
|
||||||
# * * * * * * * * * * * *
|
# * * * * * * * * * * * *
|
||||||
@ -328,7 +322,7 @@ fi
|
|||||||
# ZSH syntax highlighting plugin
|
# ZSH syntax highlighting plugin
|
||||||
ZSH_SYNTAX_HIGHLIGHT_PATH="${HOMEBREW_PREFIX}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
ZSH_SYNTAX_HIGHLIGHT_PATH="${HOMEBREW_PREFIX}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||||
if [ ! -f "$ZSH_SYNTAX_HIGHLIGHT_PATH" ]; then
|
if [ ! -f "$ZSH_SYNTAX_HIGHLIGHT_PATH" ]; then
|
||||||
ZSH_SYNTAX_HIGHLIGHT_PATH="/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
ZSH_SYNTAX_HIGHLIGHT_PATH="/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||||
fi
|
fi
|
||||||
[ -f "$ZSH_SYNTAX_HIGHLIGHT_PATH" ] && source $ZSH_SYNTAX_HIGHLIGHT_PATH
|
[ -f "$ZSH_SYNTAX_HIGHLIGHT_PATH" ] && source $ZSH_SYNTAX_HIGHLIGHT_PATH
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user