From b806643433a9fafb470792f0ba4af1a22c85df4d Mon Sep 17 00:00:00 2001 From: Bruno21 Date: Thu, 5 May 2022 09:29:19 +0200 Subject: [PATCH] 05-05-2022_2 --- .zshenv | 1 + .zshrc_pure.bak | 482 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 483 insertions(+) create mode 100644 .zshenv create mode 100644 .zshrc_pure.bak diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..c2f3182 --- /dev/null +++ b/.zshenv @@ -0,0 +1 @@ +. "$HOME/.cargo/env" diff --git a/.zshrc_pure.bak b/.zshrc_pure.bak new file mode 100644 index 0000000..516fc3b --- /dev/null +++ b/.zshrc_pure.bak @@ -0,0 +1,482 @@ +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +# --------------------------------------- +# 1.a Path +# --------------------------------------- + +export PATH="/opt/homebrew/opt/ssh-copy-id/bin:$PATH" +export PATH="/opt/homebrew/opt/unzip/bin:$PATH" +export PATH="$HOME/Documents/venv/soco-cli/bin:$PATH" +#PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH" +#PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" + +coreutils=false +if [ -d '/opt/homebrew/opt/coreutils/libexec/gnubin' ]; then + #PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" + #MANPATH="/opt/homebrew/opt/coreutils/libexec/gnuman:$MANPATH" + coreutils=true +fi + +# --------------------------------------- +# 2. antibody (plugins) +# --------------------------------------- + +# Load antibody plugin manager (http://getantibody.github.io): +source ~/.zsh_plugins.sh + +# To update plugins, run: +#antibody bundle < ~/.zsh_plugins.txt > ~/.zsh_plugins.sh + +#autoload -U promptinit; promptinit +#prompt pure + +# Theme pure: https://github.com/sindresorhus/pure +# change the path color +#zstyle :prompt:pure:path color 045 +#zstyle :prompt:pure:git:branch color white + + +# --------------------------------------- +# 3. nvm - node.js +# --------------------------------------- + +export NVM_COLORS='BrGcm' +export NVM_SYMLINK_CURRENT=true + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +export NODE_PATH=$NODE_PATH:`npm root -g` + +upd_nvm() {( + cd "$NVM_DIR" + git fetch --tags origin + git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` +) && \. "$NVM_DIR/nvm.sh" +} + + +# --------------------------------------- +# 4. Features (Z command, thefuck) +# --------------------------------------- + +# Allow the use of the z plugin to easily navigate directories +# z directory => cd /Users/bruno/directory +# https://github.com/rupa/z + +. /usr/local/etc/profile.d/z/z.sh + +# thefuck +# https://github.com/nvbn/thefuck + +eval $(thefuck --alias) + +# dircolors +# coreutils doit être installé + +eval $(gdircolors -b $HOME/.dircolors) + + +# --------------------------------------- +# 5. History +# --------------------------------------- + +HISTFILE=$HOME/.zsh_history +HISTSIZE=5000 +SAVEHIST=$HISTSIZE + +setopt extended_history # Time stamp the history, and more. +setopt hist_ignore_all_dups # remove older duplicate entries from history +setopt hist_reduce_blanks # remove superfluous blanks from history items +setopt inc_append_history # save history entries as soon as they are entered +setopt share_history # share history between different instances of the shell + +alias h='history' + + +# --------------------------------------- +# 6. Options +# --------------------------------------- + +setopt auto_cd # cd by typing directory name if it's not a command (pas besoin de taper cd, juste le nom du dossier) +setopt correct_all # autocorrect commands +setopt auto_list # automatically list choices on ambiguous completion +setopt auto_menu # automatically use menu completion +setopt always_to_end # move cursor to end if word had one match + +# Completion +zstyle ':completion:*' menu select # select completions with arrow keys +zstyle ':completion:*' group-name '' # group results by category +zstyle ':completion:::::' completer _expand _complete _ignored _approximate # enable approximate matches for completion + + +# Keybindings: +# zsh-users/zsh-history-substring-search +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down + +# delete key +#bindkey '^[[3~' delete-char +#bindkey '^[3;5~' delete-char + + +# --------------------------------------- +# 7. *** ALIAS *** +# --------------------------------------- + +alias reload='source ~/.zshrc' +alias change="bbedit ~/.zshrc" + +if $coreutils; then + cd() { builtin cd "$@" && gls -lA --color; } + alias l='gls -lA --color' + alias lt='gls -lAt --color' + alias lh='gls -dla --color .*' + # --time-style="+%d-%m-%Y %H:%M" +else + cd() { builtin cd "$@" && ls -la; } + alias l='ls -la' + alias lt='ls -lat' + alias lh='ls -a | grep "^\."' +fi + +alias backupzsh="cd && tar -czvf - .zshrc .zsh_plugins.txt .zsh_plugins.sh .sh_aliases | ssh funnymac@ftp.cluster011.ovh.net 'cat > www/backup/zsh_airbook.tar.gz'" +alias restorezsh="cd && curl https://clicclac.info/backup/zsh_airbook.tar.gz | tar -xzv && reload" + + +# --------------------------------------- +# 7.a MAKE TERMINAL BETTER +# --------------------------------------- + +alias c='clear' +# history -a -d -f -i -m -n -p(purge) -r -t +alias hc='history -c' +alias hg='history -$HISTSIZE | grep' +alias x='exit' +alias path='echo -e ${PATH//:/\\n}' + +alias nano='nano -l' +alias bb='bbedit' + +# changes directory to frontmost Finder window +alias cdf='pwdf; cd "$(pwdf)"' + +# Taille des dossiers et fichiers du répertoire courant +alias dus='du -schx * | sort -nr' + +s() { pwd > ~/.save_dir ; } +i() { cd "$(cat ~/.save_dir)" ; } +alias bk='cd $OLDPWD' + +# Extraire une archive +function ex () { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1;; + *.7z) 7z x $1 ;; + *) echo "'$1' ne peut etre extrait par ex()" ;; + esac + else + echo "'$1' fichier invalide" + fi +} + + +# ---------------------------- +# 7.b GIT +# ---------------------------- + +alias ga='git add' +alias gp='git push' +alias gl='git log' +alias gs='git status' +alias gd='git diff' +alias gc='git commit -m' +alias gca='git commit -am' +alias gb='git branch' +alias gh='git checkout' +alias gra='git remote add' +alias grr='git remote rm' +alias gpu='git pull' +alias gcl='git clone' +alias gta='git tag -a -m' +alias gf='git reflog' + +function acp() { + git add . + git commit -m "$1" + git push +} + + +# --------------------------------------- +# 7.g PYTHON +# --------------------------------------- + +# soco-cli (= sonos) +#alias sonos='$HOME/Documents/venv/soco-cli/bin/soco' +#alias sonos-discover='$HOME/Documents/venv/soco-cli/bin/soco-discover' +#alias sonos-discover='$HOME/Documents/venv/soco-cli/bin/soco-discover -t 256 -n 1.0 -m 24' +#sonos-discover() { +# $HOME/Documents/venv/soco-cli/bin/soco-discover "$@" +# } +#alias sonos-http-api-server='$HOME/Documents/venv/soco-cli/bin/soco-http-api-server' + +# Mkdocs +alias mkdocs='$HOME/Documents/venv/mkdocs/bin/mkdocs' +# servir Mkdocs (Python3) à 127.0.0.1 (-v verbose) +alias mkserve="cd $HOME/Documents/docs ; mkdocs serve" +# construire et envoyer les docs sur le serveur +alias mkbuild="/Users/bruno/Documents/Scripts/bash/mkbuild.sh" + + +# --------------------------------------- +# 7.a Homebrew +# --------------------------------------- + +alias bo='brew info' +alias bs='brew search' +alias bi='brew install' + +# brew restart apache +alias bra='brew services restart httpd' +# brew restart php +alias brp='brew services restart php' + +alias stam='brew services start mariadb' +alias stom='brew services stop mariadb' + + +# --------------------------- +# 7.c CLOUD +# --------------------------- + +alias 916e='ssh dsm916e' +alias 916='ssh dsm916' +alias 414='ssh dsm414' +alias ovh='ssh ovh' +alias 11='ssh 1and1' +alias pi3='ssh pi3' +alias pi3e='ssh pi3e' +alias pi4='ssh pi4' +alias sls='ssh vpssls' +alias mbv='ssh vpsmbv' +alias vps='ssh vps' +alias asus='ssh asus' +alias rebootasus='ssh asus /sbin/reboot' + +alias pcloud='cd $HOME/pCloud\ Drive' +alias nextcloud='cd $HOME/Nextcloud' + +# --------------------------- +# 7.d SEARCHING +# --------------------------- + +alias qfind="find / -name " # qfind: Quickly search for file +ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory +ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string +ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string + + +# --------------------------- +# 7.e NETWORKING +# --------------------------- + +#alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache +alias flushDNS='sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache' + +alias myip='curl ifconfig.me' # myip: Public facing IP Address +#alias myip='dig @resolver1.opendns.com ANY myip.opendns.com +short -4' + +alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets +alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets +alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets +alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets +alias ipinfo0='ipconfig getpacket en0' # ipInfo0: Get info on connections for en0 +alias ipinfo1='ipconfig getpacket en1' # ipInfo1: Get info on connections for en1 +alias openports='sudo lsof -i | grep LISTEN' # openPorts: All listening connections +alias showblocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs + +#alias p4="ping -c4 "$1" | grep 'received' | cut -f2 -d',' |cut -f2 -d' '" +alias ping='ping -c4' +pin() { ping -c4 "$1" | grep 'received'; } + + +# --------------------------------------- +# 7.f WEB DEVELOPMENT +# --------------------------------------- + +alias apacheTools='~/Documents/Scripts/bash/apache_tools.sh' + +alias apacheEdit='bbedit /opt/homebrew/etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf +#alias apacheRelance='sudo apachectl stop ; sleep 0.25 ; sudo apachectl start' +#alias apacheRestart='sudo apachectl -k restart' # apacheRestart: Restart Apache + +alias apal='tail -f /opt/homebrew/var/log/httpd/access_log' +alias apel='tail -f /opt/homebrew/var/log/httpd/error_log' +#alias multiapa='multitail -F /opt/homebrew/etc/multitail.conf -s 2 /opt/homebrew/var/log/httpd/error_log /usr/local/var/log/httpd/access_log' +alias multiapa='multitail -F /opt/homebrew/etc/multitail.conf -cS apache /opt/homebrew/var/log/httpd/error_log -cS apache /usr/local/var/log/httpd/access_log' +# merge +alias mtapa='multitail -ci green /opt/homebrew/var/log/httpd/access_log -ci red -I /opt/homebrew/var/log/httpd/error_log' +#multitail -F /usr/local/etc/multitail.conf -cS apache --mergeall /opt/homebrew/var/log/httpd/*access_log --no-mergeall -cS apache --mergeall /opt/homebrew/var/log/httpd/*error_log --no-mergeall + +alias log2='less +F /opt/homebrew/var/log/httpd/error_log' + +alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file +httpHeaders () { /usr/bin/curl -I -L $@ ; } # httpHeaders: Grabs headers from web page + + +# --------------------------------------- +# 7.i ALIAS GLOBAUX +# --------------------------------------- + +alias -g ...='../..' +alias -g ....='../../..' +alias -g .....='../../../..' + +alias -g C='| wc -l' + +alias -g DN=/dev/null + +alias -g H='| head' + +alias -g LL="2>&1 | less" +alias -g L="| less" +alias -g LS='| less -S' + +alias -g NE="2> /dev/null" +alias -g NUL="> /dev/null 2>&1" + +alias -g NS='| sort -n' +alias -g RNS='| sort -nr' +alias -g S='| sort' +alias -g US='| sort -u' + +alias -g TL='| tail -20' +alias -g T='| tail' + +alias -g X='| xargs' + + +# --------------------------------------- +# 7.i SONOS (soco-cli) +# --------------------------------------- + +#alias sonos-discover="/Users/bruno/Documents/venv/soco-cli/bin/sonos-discover -t 256 -n 1.0 -m 24" +alias sinfo="sonos Salon play_fav 'franceinfo'" +alias sfi="sonos Salon play_fav 'france inter'" +alias sk6="sonos Salon play_fav 'K6 FM'" +alias srtl="sonos Salon play_fav 'RTL'" +alias srire="sonos Salon play_fav 'Rire et Chansons'" +alias sflow="sonos Salon play_fav 'Flow'" +alias slist="sonos Salon list_favs" +alias smeu="sonos Salon play_fav 'Meurice'" +alias son="sonos Salon mute on" +alias soff="sonos Salon mute off" +alias sstart="sonos Salon start" +alias sstop="sonos Salon stop" +alias sv11="sonos Salon volume 11" +alias sv13="sonos Salon volume 13" +alias sv15="sonos Salon volume 15" +alias sloff="sonos Salon status_light off" +alias slon="sonos Salon status_light on" + +alias cinfo="sonos Chambre play_fav 'franceinfo'" +alias cfi="sonos Chambre play_fav 'france inter'" +alias ck6="sonos Chambre play_fav 'K6 FM'" +alias crtl="sonos Chambre play_fav 'RTL'" +alias crire="sonos Chambre play_fav 'Rire et Chansons'" +alias cflow="sonos Chambre play_fav 'Flow'" +alias sclist="sonos Chambre list_favs" +alias cmeu="sonos Chambre play_fav 'Meurice'" +alias con="sonos Chambre mute on" +alias coff="sonos Chambre mute off" +alias cstart="sonos Chambre start" +alias cstop="sonos Chambre stop" +alias cv11="sonos Chambre volume 11" +alias cv13="sonos Chambre volume 13" +alias cv15="sonos Chambre volume 15" +alias cloff="sonos Chambre status_light off" +alias clon="sonos Chambre status_light on" + + +# --------------------------------------- +# 7.i ALIAS (divers) +# --------------------------------------- + + +# Portainer & Docker +alias portainer='docker run -d -v "/var/run/docker.sock:/var/run/docker.sock" -p 9000:9000 portainer/portainer' + +alias backpi='sudo rsync -av --exclude ".*/" pi@192.168.1.100:/home/pi/ ~/RPi-backup' + +alias up_kymsu='cd /Users/bruno/Documents/Scripts/kymsu2/ ; ./install.sh' + +alias bashTools='/$HOME/Documents/Scripts/bash/bash_tools.sh' +alias zshTools='/$HOME/Documents/Scripts/bash/zsh_tools.sh' + +# Convert contents of clipboard to plain text. +alias txt='pbpaste | textutil -convert txt -stdin -stdout -encoding 30 | pbcopy' +#recupere le presse-papier et le met dans un fichier .txt +#dld() { pbpaste >> "$1".txt; } +dld() { pbpaste >> $HOME/Desktop/"$1".txt; } + +# Convertit en minuscule +alias tolowercase='pbpaste | tr "[:upper:]" "[:lower:]" | pbcopy' +#Convertit en majuscule +alias touppercase='pbpaste | tr "[:lower:]" "[:upper:]" | pbcopy' + +# Ouvrir un fichier markdow dans Typora +alias typora="open -a typora" + +# De-quarantine +alias quarantine="sudo xattr -rd com.apple.quarantine" + +# Optimise la base Mail +alias mailoptimiser="curl -sS https://raw.githubusercontent.com/pbihq/tools/master/MailDBOptimiser/MailDBOptimiser.sh | bash" + +# Multitail +alias mt='multitail -F /usr/local/etc/multitail.conf' + + +# --------------------------------------- +# 8. FONCTIONS +# --------------------------------------- + +# prints the path of the front Finder window. Desktop if no window open +function pwdf () { + osascript <