1
0
Fork 0
This commit is contained in:
Maurice Audin 2024-12-09 17:42:00 +01:00
parent 47ba7f31d0
commit 81ab085c17
12 changed files with 10 additions and 152 deletions

View file

@ -1,28 +1,13 @@
# Some exports # Some exports
export INFRA=/home/hybris/dev/bearstech/infra export INFRA=/home/${USER}/dev/bearstech/infra
export PATH=$INFRA/bin:$INFRA/../xen:$PATH export PATH=$INFRA/bin:$INFRA/service/xen:$PATH
export ANSIBLE_BEARSTECH_LOG_DIR=/var/log/ansible-bearstech
# Everyday aliases # Everyday aliases
bt-alerts() {ssh root@pidou monshow | grep -v "none$" | grep -v "^ " | grep -v "^$"} bt-alerts() {ssh root@${1:-pidou} monshow | grep -v "none$"}
bt-each() {$INFRA/bin/foreach $@}
bt-host() {cat $INFRA/host/$1}
bt-known_hosts() {scp cloud@pompon:.ssh/known_hosts ~/.ssh/known_hosts.bearstech}
bt-release() {ssh root@$1 cat /etc/debian_version} bt-release() {ssh root@$1 cat /etc/debian_version}
# Google Cloud
# The next line updates PATH for the Google Cloud SDK.
source ~/dev/bearstech/google-cloud-sdk/path.zsh.inc
# The next line enables shell command completion for gcloud.
source ~/dev/bearstech/google-cloud-sdk/completion.zsh.inc
# OVH cloud
nova-env() {source $INFRA/cloud/ovh-$1.env}
# Some completion functions # Some completion functions
_complete_bt-host() {reply=($(ls $INFRA/host))} _complete_bt-host() {reply=($(ls $INFRA/host))}
_complete_nova-env() {reply=($(ls $INFRA/cloud/ovh-*.env | sed "s@$INFRA/cloud/ovh-\(.*\).env@\1@"))}
compctl -K _complete_bt-host bt-dom0 compctl -K _complete_bt-host bt-dom0
compctl -K _complete_bt-host bt-host compctl -K _complete_bt-host infra host
compctl -K _complete_bt-host bt-release compctl -K _complete_bt-host bt-release
compctl -K _complete_nova-env nova-env

View file

@ -1,11 +0,0 @@
# Bookmarks completion using jump plugin
compctl -K _completemarks j
# Path completion on catwich
compdef _path_commands catwhich
# Hostname completion on various ssh commands
function _myssh() {compadd $(ls $INFRA/host); compadd $(ls $ROBESPIERRE/ansible/inventory | sed 's/\.yml$//')}
compdef _myssh r
compdef _myssh ra
compdef _myssh tramp

View file

@ -1,14 +0,0 @@
# Bearstech configuration
zgen load https://gitea.audin.me/hybris/zsh bearstech.zsh
# specify plugins here
zgen oh-my-zsh
zgen oh-my-zsh plugins/colored-man-pages
zgen oh-my-zsh plugins/colorize
zgen oh-my-zsh plugins/extract
zgen oh-my-zsh plugins/git
zgen oh-my-zsh plugins/jump
zgen oh-my-zsh plugins/keychain
zgen oh-my-zsh plugins/rsync
zgen oh-my-zsh plugins/systemadmin
zgen oh-my-zsh plugins/z

View file

@ -1,7 +0,0 @@
PROMPT='%{${fg_bold[green]}%}%n%{$reset_color%}%{${fg[green]}%}@%m $%{$reset_color%} '
RPROMPT='%{$fg[white]%}%~$(git_prompt_info)%{$reset_color%}%(?,,%{${fg_bold[red]}%} [%?]%{$reset_color%})'
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[green]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[green]%})%{$fg_bold[red]%}!%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%})"

View file

@ -1,55 +0,0 @@
# keychain
zstyle :omz:plugins:keychain agents gpg,ssh
zstyle :omz:plugins:keychain identities id_rsa id_ed25519 D79CA887
zstyle :omz:plugins:keychain options --quiet
# bip at command end, ensure correct window title
function precmd() {
echo -n -e "\a"
echo -en "\033]0;${USER}@$(hostname)\007"
}
# history file
unsetopt share_history
setopt INC_APPEND_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
HISTSIZE=500000
SAVEHIST=500000
# Disable reserved word foreach
disable -r foreach
# Everyday aliases
catwhich() {echo "\e[35mPath: $(which $1)\n\e[39m"; cat $(which $1)}
dontknow() {echo -n "¯\\_(ツ)_/¯" | xclip}
e() {emacsclient -n $@ > /dev/null 2>&1}
tramp() {emacsclient -n $(for x in $@; do echo /root@$x:README; done) > /dev/null 2>&1}
fd() {fdfind -H -I -L $@}
unifi-balance() {ssh ubnt@192.168.42.1 /opt/vyatta/bin/vyatta-op-cmd-wrapper 'show load-balance watchdog' 2> /dev/null}
j() {if [ $# -eq 0 ]; then marks; else jump $@; fi}
loop() {while [ 1 ]; do sh -c "$@"; done}
noprompt() {if [ "$PROMPT" != '$ ' ]; then export PROMPT='$ '; export RPROMPT=''; else source ~/.zgen/https-COLON--SLASH--SLASH-gitea.audin.me-SLASH-hybris/zsh-master/hybris.theme; fi}
open_ports() {if [ $# -eq 1 ] && [ $1 = "public" ]; then sudo netstat -tulpen 2> /dev/null | grep "LISTEN" | grep -v "127.0.0.1"; else sudo netstat -tulpen 2> /dev/null | grep "LISTEN"; fi}
r() {if [ $# -gt 0 ]; then for h in $@; do ssh root@$h; done; else sudo su -; fi}
ra() {if [ $# -gt 0 ]; then for h in $@; do ssh -A root@$h; done; else sudo su -; fi}
# Usefull bindings
bindkey "^[Od" backward-word
bindkey "^[Oc" forward-word
# Some exports
export DISABLE_AUTO_TITLE=true
export EDITOR=emacsclient
export LESS=-cex2MRX
export LESSOPEN='|~/.lessfilter %s'
export LOGCHECK=60
export READNULLCMD=${PAGER:-/usr/bin/pager}
export WATCH=all
export WATCHFMT="%n has %a %l from %M"
export ROBESPIERRE=/home/hybris/dev/robespierre/infra
export PATH=$ROBESPIERRE/bin:$HOME/.scripts:$PATH
# Fix for compdef, taken from https://github.com/seletskiy/zsh-zgen-compinit-tweak
autoload -Uz compinit && compinit -C
alias compinit='compinit-zgen'
function compinit-zgen() { grep -q ".zgen" <<< "${@}" && \compinit "${@}" }

View file

@ -10,5 +10,3 @@ zgen oh-my-zsh plugins/git
zgen oh-my-zsh plugins/jump zgen oh-my-zsh plugins/jump
zgen oh-my-zsh plugins/keychain zgen oh-my-zsh plugins/keychain
zgen oh-my-zsh plugins/rsync zgen oh-my-zsh plugins/rsync
zgen oh-my-zsh plugins/systemadmin
zgen oh-my-zsh plugins/z

View file

@ -20,14 +20,10 @@ SAVEHIST=500000
disable -r foreach disable -r foreach
# Everyday aliases # Everyday aliases
catwhich() {echo "\e[35mPath: $(which $1)\n\e[39m"; cat $(which $1)}
dontknow() {echo -n "¯\\_(ツ)_/¯" | xclip} dontknow() {echo -n "¯\\_(ツ)_/¯" | xclip}
e() {emacsclient -n $@ > /dev/null 2>&1} e() {emacsclient -n $@ > /dev/null 2>&1}
tramp() {emacsclient -n $(for x in $@; do echo /root@$x:README; done) > /dev/null 2>&1} tramp() {emacsclient -n $(for x in $@; do echo /root@$x:README; done) > /dev/null 2>&1}
fd() {fdfind -H -I -L $@}
unifi-balance() {ssh ubnt@192.168.42.1 /opt/vyatta/bin/vyatta-op-cmd-wrapper 'show load-balance watchdog' 2> /dev/null}
j() {if [ $# -eq 0 ]; then marks; else jump $@; fi} j() {if [ $# -eq 0 ]; then marks; else jump $@; fi}
loop() {while [ 1 ]; do sh -c "$@"; done}
noprompt() {if [ "$PROMPT" != '$ ' ]; then export PROMPT='$ '; export RPROMPT=''; else source ~/.zgen/https-COLON--SLASH--SLASH-gitea.audin.me-SLASH-hybris/zsh-master/hybris.theme; fi} noprompt() {if [ "$PROMPT" != '$ ' ]; then export PROMPT='$ '; export RPROMPT=''; else source ~/.zgen/https-COLON--SLASH--SLASH-gitea.audin.me-SLASH-hybris/zsh-master/hybris.theme; fi}
open_ports() {if [ $# -eq 1 ] && [ $1 = "public" ]; then sudo netstat -tulpen 2> /dev/null | grep "LISTEN" | grep -v "127.0.0.1"; else sudo netstat -tulpen 2> /dev/null | grep "LISTEN"; fi} open_ports() {if [ $# -eq 1 ] && [ $1 = "public" ]; then sudo netstat -tulpen 2> /dev/null | grep "LISTEN" | grep -v "127.0.0.1"; else sudo netstat -tulpen 2> /dev/null | grep "LISTEN"; fi}
r() {if [ $# -gt 0 ]; then for h in $@; do ssh root@$h; done; else sudo su -; fi} r() {if [ $# -gt 0 ]; then for h in $@; do ssh root@$h; done; else sudo su -; fi}
@ -46,7 +42,6 @@ export LOGCHECK=60
export READNULLCMD=${PAGER:-/usr/bin/pager} export READNULLCMD=${PAGER:-/usr/bin/pager}
export WATCH=all export WATCH=all
export WATCHFMT="%n has %a %l from %M" export WATCHFMT="%n has %a %l from %M"
export ROBESPIERRE=/home/hybris/dev/robespierre/infra
export PATH=$ROBESPIERRE/bin:$HOME/.scripts:$PATH export PATH=$ROBESPIERRE/bin:$HOME/.scripts:$PATH
# Fix for compdef, taken from https://github.com/seletskiy/zsh-zgen-compinit-tweak # Fix for compdef, taken from https://github.com/seletskiy/zsh-zgen-compinit-tweak

View file

@ -1,2 +0,0 @@
# Some completions
compctl -K _completemarks j

View file

@ -1,7 +0,0 @@
# specify plugins here
zgen oh-my-zsh
zgen oh-my-zsh plugins/colored-man-pages
zgen oh-my-zsh plugins/colorize
zgen oh-my-zsh plugins/git
zgen oh-my-zsh plugins/jump
zgen oh-my-zsh plugins/systemadmin

View file

@ -1,7 +0,0 @@
PROMPT='%U%{${fg_bold[white]}%}%n%{$reset_color%}%u%{${fg[white]}%}@%m $%{$reset_color%} '
RPROMPT='%{$fg[white]%}%~$(git_prompt_info)%{$reset_color%}%(?,,%{${fg_bold[red]}%} [%?]%{$reset_color%})'
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[green]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[green]%})%{$fg_bold[red]%}!%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%})"

View file

@ -1,19 +0,0 @@
# bip at command end, resize font
function precmd() {
echo -n -e "\a"
}
# do not share history between terms...
unsetopt share_history
# Everyday aliases
j() {if [ $# -eq 0 ]; then marks; else jump $@; fi}
# Some exports
export EDITOR=emacs
export LESS=-cex2MRX
export LESSOPEN='|~/.lessfilter %s'
export LOGCHECK=60
export READNULLCMD=${PAGER:-/usr/bin/pager}
export WATCH=all
export WATCHFMT="%n has %a %l from %M"

10
zshrc
View file

@ -1,16 +1,18 @@
# Load zgen # Load zgen
source "${HOME}/.zgen/zgen.zsh" source "${HOME}/.zgen/zgen.zsh"
zsh_config_repo=https://forgejo.audin.me/maudin/zsh
# Plugins and configuration generator # Plugins and configuration generator
if ! zgen saved; then if ! zgen saved; then
# Configuration # Configuration
zgen load https://gitea.audin.me/hybris/zsh ${USER}.zsh zgen load ${zsh_config_repo} ${USER}.zsh
# Plugins # Plugins
zgen load https://gitea.audin.me/hybris/zsh ${USER}.plugins zgen load ${zsh_config_repo} ${USER}.plugins
# Theme # Theme
zgen load https://gitea.audin.me/hybris/zsh ${USER}.theme zgen load ${zsh_config_repo} ${USER}.theme
# Completions # Completions
zgen load https://gitea.audin.me/hybris/zsh ${USER}.completions zgen load ${zsh_config_repo} ${USER}.completions
# generate the init script from plugins above # generate the init script from plugins above
zgen save zgen save