Compare commits
5 commits
8838e4f3e0
...
1db9e9af20
Author | SHA1 | Date | |
---|---|---|---|
1db9e9af20 | |||
9f31eb8183 | |||
ecbe93f3b3 | |||
cfd6ccee3b | |||
6003f7b93e |
9 changed files with 4421 additions and 458 deletions
435
.zshrc
435
.zshrc
|
@ -1,434 +1,5 @@
|
|||
# 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
|
||||
|
||||
### Source local secrets
|
||||
[ -f ${HOME}/.config/zsh/secrets ] && . ${HOME}/.config/zsh/secrets
|
||||
|
||||
## local completions
|
||||
if [ -d "${HOME}/.config/zsh/completions" ]; then
|
||||
export fpath=(${HOME}/.config/zsh/completions "${fpath[@]}")
|
||||
fi
|
||||
|
||||
### edit cmds
|
||||
export VISUAL=nvim
|
||||
autoload edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey "^X^E" edit-command-line
|
||||
### antibody
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
. ${HOME}/.config/zsh/antibody.zsh
|
||||
|
||||
### antidote
|
||||
. ~/.antidote/antidote.zsh
|
||||
antidote load
|
||||
|
||||
#. ~/.zsh_plugins.zsh
|
||||
|
||||
### fasd
|
||||
|
||||
if which fasd > /dev/null; then
|
||||
eval "$(fasd --init auto)"
|
||||
unalias sd
|
||||
fi
|
||||
|
||||
### Pipenv
|
||||
|
||||
if which pipenv > /dev/null; then
|
||||
if [ -f ${HOME}/.config/zsh/pipenv.zsh ]; then
|
||||
eval "$(cat ${HOME}/.config/zsh/pipenv.zsh)"
|
||||
else
|
||||
eval "$(pipenv --completion)"
|
||||
fi
|
||||
fi
|
||||
|
||||
### virtualenvwrapper
|
||||
|
||||
if [ -f /usr/bin/virtualenvwrapper_lazy.sh ]; then
|
||||
source /usr/bin/virtualenvwrapper_lazy.sh
|
||||
fi
|
||||
|
||||
|
||||
### FZF
|
||||
|
||||
[ -f ${HOME}/.config/zsh/fzf.zsh ] && . ${HOME}/.config/zsh/fzf.zsh
|
||||
|
||||
### ASDF
|
||||
|
||||
if [ -d /opt/asdf-vm ]; then
|
||||
. /opt/asdf-vm/asdf.sh
|
||||
fi
|
||||
|
||||
### Misc
|
||||
|
||||
## TERM
|
||||
# Many target machines do not understand TERM=xterm-kitty
|
||||
if [ "z${TMUX}" = "z" ]; then
|
||||
function ssh {
|
||||
TERM=xterm-color /bin/ssh ${@}
|
||||
}
|
||||
fi
|
||||
|
||||
if [[ ! -z $TMUX ]]; then
|
||||
export TERM=tmux-256color
|
||||
export TMUX_BASE=$(tmux display -p '#{pane_current_path}')
|
||||
fi
|
||||
|
||||
## Editor
|
||||
export EDITOR=nvim
|
||||
|
||||
## Locale
|
||||
export LANG=.UTF-8
|
||||
export LANGUAGE=en_US
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
export LC_NUMERIC=en_US.UTF-8
|
||||
export LC_TIME=it_IT.UTF-8
|
||||
export LC_COLLATE=en_US.UTF-8
|
||||
export LC_MONETARY=it_IT.UTF-8
|
||||
export LC_MESSAGES=en_US.UTF-8
|
||||
export LC_PAPER=it_IT.UTF-8
|
||||
export LC_NAME=en_US.UTF-8
|
||||
export LC_ADDRESS=en_US.UTF-8
|
||||
export LC_TELEPHONE=en_US.UTF-8
|
||||
export LC_MEASUREMENT=it_IT.UTF-8
|
||||
export LC_IDENTIFICATION=en_US.UTF-8
|
||||
export LC_ALL=
|
||||
|
||||
## Flutter && Dart
|
||||
export ANDROID_SDK=${HOME}/Android/Sdk
|
||||
export PATH=${ANDROID_SDK}/emulator:${ANDROID_SDK}/tools:$PATH
|
||||
export PATH=/opt/flutter/bin/:"$HOME/.pub-cache/bin":$PATH
|
||||
export CHROME_EXECUTABLE=/usr/bin/chromium
|
||||
|
||||
## Go
|
||||
export GOPATH=${HOME}/.go
|
||||
export PATH=${GOPATH}/bin:$PATH
|
||||
|
||||
## Ruby
|
||||
#export PATH=${PATH}:/home/leo/.gem/ruby/2.7.0/bin
|
||||
|
||||
## Elixir
|
||||
export ERL_AFLAGS="-kernel shell_history enabled"
|
||||
|
||||
## Python
|
||||
PYTHON_VERSION=$(python -c 'import sys; print("{}.{}".format(*sys.version_info[0:2]))')
|
||||
|
||||
## Aliases
|
||||
alias t="tmux -2"
|
||||
alias sy="systemctl"
|
||||
alias ssy="sudo systemctl"
|
||||
alias syu="systemctl --user"
|
||||
alias sl="cmatrix -b -s"
|
||||
alias cd..="cmatrix -b -s -C yellow"
|
||||
alias lt="ls -lt"
|
||||
alias l="ls -1"
|
||||
alias lh="ls -lh"
|
||||
alias la="ls -la"
|
||||
alias ll="ls -l"
|
||||
alias lrt="ls -lrt"
|
||||
alias wgpg="gpg --homedir /home/leo/.gnupg-sysdig"
|
||||
alias agpg="gpg --homedir /home/leo/.gnupg-ai"
|
||||
alias ai_all="cat ${HOME}/code/ai/prod/hosts.yml|yq '[.hosts|to_entries[]|{"key": .key, "value": .value.groups}]|from_entries'"
|
||||
alias pacbrowse="pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'"
|
||||
alias pikbrowse="pikaur -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pikaur -Qil {} | less)'"
|
||||
alias vf="cd \$(git rev-parse --show-toplevel)"
|
||||
alias vvf="cd \$(${HOME}/.bin/vvf.sh)"
|
||||
alias vim="vim -T xterm"
|
||||
|
||||
## Drone CLI
|
||||
|
||||
export DRONE_SERVER=https://drone.troubles.io
|
||||
export DRONE_TOKEN=${drone_token}
|
||||
|
||||
# ensure Git completion
|
||||
fpath+=/usr/share/git/completion
|
||||
|
||||
## mailbundle
|
||||
export MAILDIR="${HOME}/Mail"
|
||||
alias mutt="neomutt"
|
||||
alias mailbundle="${MAILDIR}/mailbundle/config/bin/autorun"
|
||||
|
||||
## torbrowser
|
||||
export PATH=/opt/tor-browser_en-US:$PATH
|
||||
|
||||
## platform-tools
|
||||
export PATH=/opt/android-sdk/platform-tools:$PATH
|
||||
|
||||
## Custom functions
|
||||
function ,lookhosts {
|
||||
if which rg 2>&1 > /dev/null; then
|
||||
GREP=rg
|
||||
else
|
||||
GREP=grep
|
||||
fi
|
||||
${GREP} $@ /etc/hosts
|
||||
}
|
||||
|
||||
function ,sway-screens {
|
||||
local screens=$(swaymsg -t get_outputs -r)
|
||||
local show_active
|
||||
local show_inactive
|
||||
local var_style="plain"
|
||||
local active_screens=()
|
||||
local inactive_screens=()
|
||||
|
||||
while [ $# -ne 0 ]; do
|
||||
case $1 in
|
||||
-a|--active)
|
||||
show_active=1
|
||||
;;
|
||||
-n|--inactive)
|
||||
show_inactive=1
|
||||
;;
|
||||
-s|--style)
|
||||
case $2 in
|
||||
json)
|
||||
var_style="json"
|
||||
;;
|
||||
plain)
|
||||
;;
|
||||
*)
|
||||
echo "unknown style ${2}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "z${show_active}" != "z" ]; then
|
||||
for s in $(echo $screens|jq -r '.[] | select(.active) | .name'); do
|
||||
active_screens+=($s)
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "z${show_inactive}" != "z" ]; then
|
||||
for s in $(echo $screens|jq -r '.[] | select(.active|not) | .name'); do
|
||||
inactive_screens+=($s)
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "${var_style}" = "plain" ]; then
|
||||
if [ ${#active_screens[@]} -gt 0 ]; then
|
||||
echo "ACTIVE=${active_screens[@]}"
|
||||
fi
|
||||
if [ ${#inactive_screens[@]} -gt 0 ]; then
|
||||
echo "INACTIVE=${inactive_screens[@]}"
|
||||
fi
|
||||
else
|
||||
local active=""
|
||||
for s in $active_screens; do
|
||||
active+="\"$s\","
|
||||
done
|
||||
active=${active%,}
|
||||
|
||||
local inactive=""
|
||||
for s in $inactive_screens; do
|
||||
inactive+="\"$s\","
|
||||
done
|
||||
inactive=${inactive%,}
|
||||
|
||||
local content=""
|
||||
if [ "z${show_active}" != "z" ]; then
|
||||
content+="\"active\": [${active}],"
|
||||
fi
|
||||
if [ "z${show_inactive}" != "z" ]; then
|
||||
content+="\"inactive\": [${inactive}],"
|
||||
fi
|
||||
content=${content%,}
|
||||
|
||||
echo "{${content}}" | jq
|
||||
fi
|
||||
}
|
||||
|
||||
function ,urlencode() {
|
||||
# urlencode <string>
|
||||
|
||||
old_lc_collate=$LC_COLLATE
|
||||
LC_COLLATE=C
|
||||
|
||||
local length="${#1}"
|
||||
for (( i = 0; i < length; i++ )); do
|
||||
local c="${1:$i:1}"
|
||||
case $c in
|
||||
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
|
||||
*) printf '%%%02X' "'$c" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
LC_COLLATE=$old_lc_collate
|
||||
}
|
||||
|
||||
urldecode() {
|
||||
# urldecode <string>
|
||||
|
||||
local url_encoded="${1//+/ }"
|
||||
printf '%b' "${url_encoded//%/\\x}"
|
||||
}
|
||||
|
||||
ce() {
|
||||
if [ "z$TMUX" != "z" ] && [ "z$TMUX_BASE" != "z" ] ; then
|
||||
cd $()
|
||||
cd $TMUX_BASE
|
||||
else
|
||||
cd
|
||||
fi
|
||||
}
|
||||
|
||||
## Custom completion
|
||||
# certo
|
||||
if which certo > /dev/null; then
|
||||
eval "$(_CERTO_COMPLETE=source_zsh certo)"
|
||||
fi
|
||||
|
||||
## powerline
|
||||
|
||||
if which powerline-daemon > /dev/null; then
|
||||
powerline-daemon -q
|
||||
. /usr/lib/python${PYTHON_VERSION}/site-packages/powerline/bindings/zsh/powerline.zsh
|
||||
fi
|
||||
|
||||
## Colored manual
|
||||
|
||||
function color_man() {
|
||||
man $@ | bat -p --language="man"
|
||||
}
|
||||
|
||||
alias man="color_man"
|
||||
|
||||
## Local only
|
||||
|
||||
if [ -f ${HOME}/.zshrc.local ]; then
|
||||
. ${HOME}/.zshrc.local
|
||||
fi
|
||||
|
||||
### atuin (shell history)
|
||||
export ATUIN_NOBIND="true"
|
||||
eval "$(atuin init zsh)"
|
||||
|
||||
bindkey '^r' _atuin_search_widget
|
||||
|
||||
### broot
|
||||
source /home/leo/.config/broot/launcher/bash/br
|
||||
|
||||
### A/I
|
||||
if [ -f ${HOME}/.zshrc.ai ]; then
|
||||
source ${HOME}/.zshrc.ai
|
||||
fi
|
||||
|
||||
### colored and fuzzy go doc
|
||||
if which bat > /dev/null; then
|
||||
function _godoc() {
|
||||
if echo $1|grep -q -E "^([a-zA-Z0-9/]+)$"; then
|
||||
go doc ${@} | bat -p -l md
|
||||
elif echo $1|grep -q -E "^[a-zA-Z0-9/]+\.[a-zA-Z0-9.]+$"; then
|
||||
go doc ${@} | bat -p -l go
|
||||
elif echo $1|grep -q -E "^([a-zA-Z0-9/._-]+)/.*\.[a-zA-Z0-9.]+$"; then
|
||||
go doc ${@} | bat -p -l go
|
||||
else
|
||||
go doc ${@} | bat -p -l md
|
||||
fi
|
||||
}
|
||||
if [[ $TTY == *tty* ]]; then
|
||||
source .zshrc.tty
|
||||
else
|
||||
function _godoc() {
|
||||
go doc ${@}
|
||||
}
|
||||
source .zshrc.graphic
|
||||
fi
|
||||
|
||||
function gomodroot() {
|
||||
. <(go env|grep -E "^GOMOD")
|
||||
echo ${GOMOD%%go.mod}
|
||||
unset GOMOD
|
||||
}
|
||||
|
||||
function _godocbuildcache() {
|
||||
local VERSION="$(go version|awk '{print $3}')"
|
||||
local DOCCACHE="${GODOC_CACHE:-${HOME}/.cache/godoc}/${VERSION}"
|
||||
if [ -d ${DOCCACHE} ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "generating stdlib godoc cache, wait some time" 1>&2
|
||||
|
||||
mkdir -p ${DOCCACHE}
|
||||
for DEP in $(go list std|grep -v -E "internal/"); do
|
||||
go doc -short ${DEP}|sed -e 's/^\ *\(func\|type\|const\|var\)\ \([a-zA-Z0-9]\+\).*/\2/'|xargs -I {} echo ${DEP}.{} 2>/dev/null >> ${DOCCACHE}/stdlib.symbols
|
||||
done
|
||||
|
||||
echo "done generating stdlib godoc cache" 1>&2
|
||||
}
|
||||
|
||||
function _godocenum() {
|
||||
_godocbuildcache
|
||||
local VERSION="$(go version|awk '{print $3}')"
|
||||
local DOCCACHE="${GODOC_CACHE:-${HOME}/.cache/godoc}/${VERSION}"
|
||||
cat ${DOCCACHE}/stdlib.symbols
|
||||
|
||||
for DEP in $(go list -f '{{ join .Deps "\n" }}' $(gomodroot)/...); do
|
||||
for SYM in $(go doc -short ${DEP}|sed -e 's/^\ *\(func\|type\|const\|var\)\ \([a-zA-Z0-9]\+\).*/\2/'); do
|
||||
echo ${DEP}.${SYM}
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
function ,godoc() {
|
||||
if [ $# -eq 0 ]; then
|
||||
if which bat > /dev/null; then
|
||||
OBJ=$(_godocenum|fzf --height=80% --info=inline --reverse --border --margin=1 --padding=1 --preview="go doc {1}|bat --color always -p -l go")
|
||||
else
|
||||
OBJ=$(_godocenum|fzf --height=80% --info=inline --reverse --border --margin=1 --padding=1 --preview="go doc {1}")
|
||||
fi
|
||||
_godoc ${OBJ}
|
||||
else
|
||||
_godoc ${@}
|
||||
fi
|
||||
}
|
||||
|
||||
### paste.sr.ht
|
||||
|
||||
function ,pasteit() {
|
||||
hut paste create ${@}
|
||||
}
|
||||
|
||||
### piknik
|
||||
|
||||
# pko <content> : copy <content> to the clipboard
|
||||
function ,pko() {
|
||||
echo "$*" | piknik -copy
|
||||
}
|
||||
|
||||
# pkf <file> : copy the content of <file> to the clipboard
|
||||
function ,pkf() {
|
||||
piknik -copy < $1
|
||||
}
|
||||
|
||||
# pkc : read the content to copy to the clipboard from STDIN
|
||||
alias ,pkc='piknik -copy'
|
||||
|
||||
# pkp : paste the clipboard content
|
||||
alias ,pkp='piknik -paste'
|
||||
|
||||
# pkm : move the clipboard content
|
||||
alias ,pkm='piknik -move'
|
||||
|
||||
# pkz : delete the clipboard content
|
||||
alias ,pkz='piknik -copy < /dev/null'
|
||||
|
||||
# pkfr [<dir>] : send a whole directory to the clipboard, as a tar archive
|
||||
function ,pkfr() {
|
||||
tar czpvf - ${1:-.} | piknik -copy
|
||||
}
|
||||
|
||||
# pkpr : extract clipboard content sent using the pkfr command
|
||||
alias ,pkpr='piknik -paste | tar xzpvf -'
|
||||
|
||||
# vim: set ft=zsh et sw=0 ts=2 sts=0:
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
|
|
434
.zshrc.graphic
Normal file
434
.zshrc.graphic
Normal file
|
@ -0,0 +1,434 @@
|
|||
# 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
|
||||
|
||||
### Source local secrets
|
||||
[ -f ${HOME}/.config/zsh/secrets ] && . ${HOME}/.config/zsh/secrets
|
||||
|
||||
## local completions
|
||||
if [ -d "${HOME}/.config/zsh/completions" ]; then
|
||||
export fpath=(${HOME}/.config/zsh/completions "${fpath[@]}")
|
||||
fi
|
||||
|
||||
### edit cmds
|
||||
export VISUAL=nvim
|
||||
autoload edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey "^X^E" edit-command-line
|
||||
### antibody
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
. ${HOME}/.config/zsh/antibody.zsh
|
||||
|
||||
### antidote
|
||||
. ~/.antidote/antidote.zsh
|
||||
antidote load
|
||||
|
||||
#. ~/.zsh_plugins.zsh
|
||||
|
||||
### fasd
|
||||
|
||||
if which fasd > /dev/null; then
|
||||
eval "$(fasd --init auto)"
|
||||
unalias sd
|
||||
fi
|
||||
|
||||
### Pipenv
|
||||
|
||||
if which pipenv > /dev/null; then
|
||||
if [ -f ${HOME}/.config/zsh/pipenv.zsh ]; then
|
||||
eval "$(cat ${HOME}/.config/zsh/pipenv.zsh)"
|
||||
else
|
||||
eval "$(pipenv --completion)"
|
||||
fi
|
||||
fi
|
||||
|
||||
### virtualenvwrapper
|
||||
|
||||
if [ -f /usr/bin/virtualenvwrapper_lazy.sh ]; then
|
||||
source /usr/bin/virtualenvwrapper_lazy.sh
|
||||
fi
|
||||
|
||||
|
||||
### FZF
|
||||
|
||||
[ -f ${HOME}/.config/zsh/fzf.zsh ] && . ${HOME}/.config/zsh/fzf.zsh
|
||||
|
||||
### ASDF
|
||||
|
||||
if [ -d /opt/asdf-vm ]; then
|
||||
. /opt/asdf-vm/asdf.sh
|
||||
fi
|
||||
|
||||
### Misc
|
||||
|
||||
## TERM
|
||||
# Many target machines do not understand TERM=xterm-kitty
|
||||
if [ "z${TMUX}" = "z" ]; then
|
||||
function ssh {
|
||||
TERM=xterm-color /bin/ssh ${@}
|
||||
}
|
||||
fi
|
||||
|
||||
if [[ ! -z $TMUX ]]; then
|
||||
export TERM=tmux-256color
|
||||
export TMUX_BASE=$(tmux display -p '#{pane_current_path}')
|
||||
fi
|
||||
|
||||
## Editor
|
||||
export EDITOR=nvim
|
||||
|
||||
## Locale
|
||||
export LANG=.UTF-8
|
||||
export LANGUAGE=en_US
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
export LC_NUMERIC=en_US.UTF-8
|
||||
export LC_TIME=it_IT.UTF-8
|
||||
export LC_COLLATE=en_US.UTF-8
|
||||
export LC_MONETARY=it_IT.UTF-8
|
||||
export LC_MESSAGES=en_US.UTF-8
|
||||
export LC_PAPER=it_IT.UTF-8
|
||||
export LC_NAME=en_US.UTF-8
|
||||
export LC_ADDRESS=en_US.UTF-8
|
||||
export LC_TELEPHONE=en_US.UTF-8
|
||||
export LC_MEASUREMENT=it_IT.UTF-8
|
||||
export LC_IDENTIFICATION=en_US.UTF-8
|
||||
export LC_ALL=
|
||||
|
||||
## Flutter && Dart
|
||||
export ANDROID_SDK=${HOME}/Android/Sdk
|
||||
export PATH=${ANDROID_SDK}/emulator:${ANDROID_SDK}/tools:$PATH
|
||||
export PATH=/opt/flutter/bin/:"$HOME/.pub-cache/bin":$PATH
|
||||
export CHROME_EXECUTABLE=/usr/bin/chromium
|
||||
|
||||
## Go
|
||||
export GOPATH=${HOME}/.go
|
||||
export PATH=${GOPATH}/bin:$PATH
|
||||
|
||||
## Ruby
|
||||
#export PATH=${PATH}:/home/leo/.gem/ruby/2.7.0/bin
|
||||
|
||||
## Elixir
|
||||
export ERL_AFLAGS="-kernel shell_history enabled"
|
||||
|
||||
## Python
|
||||
PYTHON_VERSION=$(python -c 'import sys; print("{}.{}".format(*sys.version_info[0:2]))')
|
||||
|
||||
## Aliases
|
||||
alias t="tmux -2"
|
||||
alias sy="systemctl"
|
||||
alias ssy="sudo systemctl"
|
||||
alias syu="systemctl --user"
|
||||
alias sl="cmatrix -b -s"
|
||||
alias cd..="cmatrix -b -s -C yellow"
|
||||
alias lt="ls -lt"
|
||||
alias l="ls -1"
|
||||
alias lh="ls -lh"
|
||||
alias la="ls -la"
|
||||
alias ll="ls -l"
|
||||
alias lrt="ls -lrt"
|
||||
alias wgpg="gpg --homedir /home/leo/.gnupg-sysdig"
|
||||
alias agpg="gpg --homedir /home/leo/.gnupg-ai"
|
||||
alias ai_all="cat ${HOME}/code/ai/prod/hosts.yml|yq '[.hosts|to_entries[]|{"key": .key, "value": .value.groups}]|from_entries'"
|
||||
alias pacbrowse="pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'"
|
||||
alias pikbrowse="pikaur -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pikaur -Qil {} | less)'"
|
||||
alias vf="cd \$(git rev-parse --show-toplevel)"
|
||||
alias vvf="cd \$(${HOME}/.bin/vvf.sh)"
|
||||
alias vim="vim -T xterm"
|
||||
|
||||
## Drone CLI
|
||||
|
||||
export DRONE_SERVER=https://drone.troubles.io
|
||||
export DRONE_TOKEN=${drone_token}
|
||||
|
||||
# ensure Git completion
|
||||
fpath+=/usr/share/git/completion
|
||||
|
||||
## mailbundle
|
||||
export MAILDIR="${HOME}/Mail"
|
||||
alias mutt="neomutt"
|
||||
alias mailbundle="${MAILDIR}/mailbundle/config/bin/autorun"
|
||||
|
||||
## torbrowser
|
||||
export PATH=/opt/tor-browser_en-US:$PATH
|
||||
|
||||
## platform-tools
|
||||
export PATH=/opt/android-sdk/platform-tools:$PATH
|
||||
|
||||
## Custom functions
|
||||
function ,lookhosts {
|
||||
if which rg 2>&1 > /dev/null; then
|
||||
GREP=rg
|
||||
else
|
||||
GREP=grep
|
||||
fi
|
||||
${GREP} $@ /etc/hosts
|
||||
}
|
||||
|
||||
function ,sway-screens {
|
||||
local screens=$(swaymsg -t get_outputs -r)
|
||||
local show_active
|
||||
local show_inactive
|
||||
local var_style="plain"
|
||||
local active_screens=()
|
||||
local inactive_screens=()
|
||||
|
||||
while [ $# -ne 0 ]; do
|
||||
case $1 in
|
||||
-a|--active)
|
||||
show_active=1
|
||||
;;
|
||||
-n|--inactive)
|
||||
show_inactive=1
|
||||
;;
|
||||
-s|--style)
|
||||
case $2 in
|
||||
json)
|
||||
var_style="json"
|
||||
;;
|
||||
plain)
|
||||
;;
|
||||
*)
|
||||
echo "unknown style ${2}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "z${show_active}" != "z" ]; then
|
||||
for s in $(echo $screens|jq -r '.[] | select(.active) | .name'); do
|
||||
active_screens+=($s)
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "z${show_inactive}" != "z" ]; then
|
||||
for s in $(echo $screens|jq -r '.[] | select(.active|not) | .name'); do
|
||||
inactive_screens+=($s)
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "${var_style}" = "plain" ]; then
|
||||
if [ ${#active_screens[@]} -gt 0 ]; then
|
||||
echo "ACTIVE=${active_screens[@]}"
|
||||
fi
|
||||
if [ ${#inactive_screens[@]} -gt 0 ]; then
|
||||
echo "INACTIVE=${inactive_screens[@]}"
|
||||
fi
|
||||
else
|
||||
local active=""
|
||||
for s in $active_screens; do
|
||||
active+="\"$s\","
|
||||
done
|
||||
active=${active%,}
|
||||
|
||||
local inactive=""
|
||||
for s in $inactive_screens; do
|
||||
inactive+="\"$s\","
|
||||
done
|
||||
inactive=${inactive%,}
|
||||
|
||||
local content=""
|
||||
if [ "z${show_active}" != "z" ]; then
|
||||
content+="\"active\": [${active}],"
|
||||
fi
|
||||
if [ "z${show_inactive}" != "z" ]; then
|
||||
content+="\"inactive\": [${inactive}],"
|
||||
fi
|
||||
content=${content%,}
|
||||
|
||||
echo "{${content}}" | jq
|
||||
fi
|
||||
}
|
||||
|
||||
function ,urlencode() {
|
||||
# urlencode <string>
|
||||
|
||||
old_lc_collate=$LC_COLLATE
|
||||
LC_COLLATE=C
|
||||
|
||||
local length="${#1}"
|
||||
for (( i = 0; i < length; i++ )); do
|
||||
local c="${1:$i:1}"
|
||||
case $c in
|
||||
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
|
||||
*) printf '%%%02X' "'$c" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
LC_COLLATE=$old_lc_collate
|
||||
}
|
||||
|
||||
urldecode() {
|
||||
# urldecode <string>
|
||||
|
||||
local url_encoded="${1//+/ }"
|
||||
printf '%b' "${url_encoded//%/\\x}"
|
||||
}
|
||||
|
||||
ce() {
|
||||
if [ "z$TMUX" != "z" ] && [ "z$TMUX_BASE" != "z" ] ; then
|
||||
cd $()
|
||||
cd $TMUX_BASE
|
||||
else
|
||||
cd
|
||||
fi
|
||||
}
|
||||
|
||||
## Custom completion
|
||||
# certo
|
||||
if which certo > /dev/null; then
|
||||
eval "$(_CERTO_COMPLETE=source_zsh certo)"
|
||||
fi
|
||||
|
||||
## powerline
|
||||
|
||||
if which powerline-daemon > /dev/null; then
|
||||
powerline-daemon -q
|
||||
. /usr/lib/python${PYTHON_VERSION}/site-packages/powerline/bindings/zsh/powerline.zsh
|
||||
fi
|
||||
|
||||
## Colored manual
|
||||
|
||||
function color_man() {
|
||||
man $@ | bat -p --language="man"
|
||||
}
|
||||
|
||||
alias man="color_man"
|
||||
|
||||
## Local only
|
||||
|
||||
if [ -f ${HOME}/.zshrc.local ]; then
|
||||
. ${HOME}/.zshrc.local
|
||||
fi
|
||||
|
||||
### atuin (shell history)
|
||||
export ATUIN_NOBIND="true"
|
||||
eval "$(atuin init zsh)"
|
||||
|
||||
bindkey '^r' _atuin_search_widget
|
||||
|
||||
### broot
|
||||
source /home/leo/.config/broot/launcher/bash/br
|
||||
|
||||
### A/I
|
||||
if [ -f ${HOME}/.zshrc.ai ]; then
|
||||
source ${HOME}/.zshrc.ai
|
||||
fi
|
||||
|
||||
### colored and fuzzy go doc
|
||||
if which bat > /dev/null; then
|
||||
function _godoc() {
|
||||
if echo $1|grep -q -E "^([a-zA-Z0-9/]+)$"; then
|
||||
go doc ${@} | bat -p -l md
|
||||
elif echo $1|grep -q -E "^[a-zA-Z0-9/]+\.[a-zA-Z0-9.]+$"; then
|
||||
go doc ${@} | bat -p -l go
|
||||
elif echo $1|grep -q -E "^([a-zA-Z0-9/._-]+)/.*\.[a-zA-Z0-9.]+$"; then
|
||||
go doc ${@} | bat -p -l go
|
||||
else
|
||||
go doc ${@} | bat -p -l md
|
||||
fi
|
||||
}
|
||||
else
|
||||
function _godoc() {
|
||||
go doc ${@}
|
||||
}
|
||||
fi
|
||||
|
||||
function gomodroot() {
|
||||
. <(go env|grep -E "^GOMOD")
|
||||
echo ${GOMOD%%go.mod}
|
||||
unset GOMOD
|
||||
}
|
||||
|
||||
function _godocbuildcache() {
|
||||
local VERSION="$(go version|awk '{print $3}')"
|
||||
local DOCCACHE="${GODOC_CACHE:-${HOME}/.cache/godoc}/${VERSION}"
|
||||
if [ -d ${DOCCACHE} ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "generating stdlib godoc cache, wait some time" 1>&2
|
||||
|
||||
mkdir -p ${DOCCACHE}
|
||||
for DEP in $(go list std|grep -v -E "internal/"); do
|
||||
go doc -short ${DEP}|sed -e 's/^\ *\(func\|type\|const\|var\)\ \([a-zA-Z0-9]\+\).*/\2/'|xargs -I {} echo ${DEP}.{} 2>/dev/null >> ${DOCCACHE}/stdlib.symbols
|
||||
done
|
||||
|
||||
echo "done generating stdlib godoc cache" 1>&2
|
||||
}
|
||||
|
||||
function _godocenum() {
|
||||
_godocbuildcache
|
||||
local VERSION="$(go version|awk '{print $3}')"
|
||||
local DOCCACHE="${GODOC_CACHE:-${HOME}/.cache/godoc}/${VERSION}"
|
||||
cat ${DOCCACHE}/stdlib.symbols
|
||||
|
||||
for DEP in $(go list -f '{{ join .Deps "\n" }}' $(gomodroot)/...); do
|
||||
for SYM in $(go doc -short ${DEP}|sed -e 's/^\ *\(func\|type\|const\|var\)\ \([a-zA-Z0-9]\+\).*/\2/'); do
|
||||
echo ${DEP}.${SYM}
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
function ,godoc() {
|
||||
if [ $# -eq 0 ]; then
|
||||
if which bat > /dev/null; then
|
||||
OBJ=$(_godocenum|fzf --height=80% --info=inline --reverse --border --margin=1 --padding=1 --preview="go doc {1}|bat --color always -p -l go")
|
||||
else
|
||||
OBJ=$(_godocenum|fzf --height=80% --info=inline --reverse --border --margin=1 --padding=1 --preview="go doc {1}")
|
||||
fi
|
||||
_godoc ${OBJ}
|
||||
else
|
||||
_godoc ${@}
|
||||
fi
|
||||
}
|
||||
|
||||
### paste.sr.ht
|
||||
|
||||
function ,pasteit() {
|
||||
hut paste create ${@}
|
||||
}
|
||||
|
||||
### piknik
|
||||
|
||||
# pko <content> : copy <content> to the clipboard
|
||||
function ,pko() {
|
||||
echo "$*" | piknik -copy
|
||||
}
|
||||
|
||||
# pkf <file> : copy the content of <file> to the clipboard
|
||||
function ,pkf() {
|
||||
piknik -copy < $1
|
||||
}
|
||||
|
||||
# pkc : read the content to copy to the clipboard from STDIN
|
||||
alias ,pkc='piknik -copy'
|
||||
|
||||
# pkp : paste the clipboard content
|
||||
alias ,pkp='piknik -paste'
|
||||
|
||||
# pkm : move the clipboard content
|
||||
alias ,pkm='piknik -move'
|
||||
|
||||
# pkz : delete the clipboard content
|
||||
alias ,pkz='piknik -copy < /dev/null'
|
||||
|
||||
# pkfr [<dir>] : send a whole directory to the clipboard, as a tar archive
|
||||
function ,pkfr() {
|
||||
tar czpvf - ${1:-.} | piknik -copy
|
||||
}
|
||||
|
||||
# pkpr : extract clipboard content sent using the pkfr command
|
||||
alias ,pkpr='piknik -paste | tar xzpvf -'
|
||||
|
||||
# vim: set ft=zsh et sw=0 ts=2 sts=0:
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
3957
.zshrc.tty
Normal file
3957
.zshrc.tty
Normal file
File diff suppressed because it is too large
Load diff
12
install.sh
Executable file
12
install.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
|
||||
for SCRIPT in update_*; do
|
||||
./${SCRIPT}
|
||||
done
|
||||
|
||||
for CONFIG in .zshrc*; do
|
||||
! [ -f ${HOME}/${CONFIG} ] && ln -s $PWD/${CONFIG} ${HOME}/${CONFIG}
|
||||
done
|
||||
|
||||
# vim:set et ts=4 sts=0 sw=0 ft=zsh:
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
echo "Updating antibody cache"
|
||||
|
||||
currpath=$(realpath $PWD)
|
||||
|
||||
if [ ! -d ${currpath}/compiled ]; then
|
||||
mkdir compiled
|
||||
fi
|
||||
|
||||
antibody_bin=$(which antibody)
|
||||
if [ "z${antibody_bin}" = "z" ]; then
|
||||
echo "Error: you need to install antibody first!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
${antibody_bin} bundle < ${currpath}/antibody.plugins.txt > ${currpath}/compiled/antibody.zsh
|
||||
if [ ! -d ~/.config/zsh ]; then
|
||||
mkdir -p ~/.config/zsh
|
||||
fi
|
||||
cp ${currpath}/compiled/antibody.zsh ~/.config/zsh/
|
||||
|
||||
# vim: set ft=sh et sw=0 ts=2 sts=0:
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
echo "=> Updating antidote"
|
||||
|
||||
! [[ -z $DEBUG ]] && set -x
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
echo "Updating fzf"
|
||||
echo "=> Updating fzf"
|
||||
|
||||
currpath=$(realpath $PWD)
|
||||
|
||||
|
@ -16,4 +16,4 @@ if [ ! -d ~/.config/zsh ]; then
|
|||
fi
|
||||
cp ${currpath}/fzf.zsh ${HOME}/.config/zsh/
|
||||
|
||||
# vim: set ft=sh et sw=0 ts=2 sts=0:
|
||||
# vim: set ft=zsh et sw=0 ts=2 sts=0:
|
||||
|
|
10
update_grml_zsh.sh
Executable file
10
update_grml_zsh.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env zsh
|
||||
echo "=> Updating grml zsh config"
|
||||
|
||||
curl --fail \
|
||||
-L \
|
||||
--output /tmp/.zshrc.tty \
|
||||
https://git.grml.org/f/grml-etc-core/etc/zsh/zshrc \
|
||||
&& mv /tmp/.zshrc.tty .zshrc.tty
|
||||
|
||||
# vim: set ft=zsh et sw=0 ts=2 sts=0:
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
echo "Updating pipenv completion"
|
||||
echo "=> Updating pipenv completion"
|
||||
|
||||
currpath=$(realpath $PWD)
|
||||
|
||||
|
@ -19,4 +19,4 @@ if [ ! -d ~/.config/zsh ]; then
|
|||
fi
|
||||
cp ${currpath}/compiled/pipenv.zsh ~/.config/zsh/pipenv.zsh
|
||||
|
||||
# vim: set ft=sh et sw=0 ts=2 sts=0:
|
||||
# vim: set ft=zsh et sw=0 ts=2 sts=0:
|
||||
|
|
Loading…
Reference in a new issue