723 lines
23 KiB
Bash
723 lines
23 KiB
Bash
# 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
|
|
|
|
|
|
# ---------------------------------------
|
|
# 1. fzf
|
|
# ---------------------------------------
|
|
|
|
#https://github.com/junegunn/fzf/wiki/
|
|
|
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
|
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
|
|
#export FZF_DEFAULT_COMMAND="find ."
|
|
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow'
|
|
# --preview "bat --style=numbers --color=always --line-range :500 {}" --preview="head -$LINES {}"
|
|
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
|
|
bindkey "ç" fzf-cd-widget
|
|
|
|
fif() {
|
|
if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi
|
|
rg --files-with-matches --no-messages "$1" | fzf --preview "highlight -O ansi -l {} 2> /dev/null | rg --colors 'match:bg:yellow' --ignore-case --pretty --context 10 '$1' || rg --ignore-case --pretty --context 10 '$1' {}"
|
|
}
|
|
|
|
# find-in-file - usage: fif <searchTerm> or fif "string with spaces" or fif "regex"
|
|
fif() {
|
|
if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi
|
|
local file
|
|
file="$(rga --max-count=1 --ignore-case --files-with-matches --no-messages "$*" | fzf-tmux +m --preview="rga --ignore-case --pretty --context 10 '"$*"' {}")" && echo "opening $file" && open "$file" || return 1;
|
|
}
|
|
|
|
# ---------------------------------------
|
|
# 2. Path
|
|
# ---------------------------------------
|
|
|
|
# keg-only
|
|
export PATH="/opt/homebrew/opt/ssh-copy-id/bin:$PATH"
|
|
export PATH="/opt/homebrew/opt/unzip/bin:$PATH"
|
|
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
|
|
|
|
#PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
|
|
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
|
|
PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
|
|
|
|
# poetry
|
|
export PATH="/Users/bruno/Library/Python/3.9/bin:$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
|
|
|
|
#export PATH="$HOME/Documents/venv/soco-cli/bin:$PATH"
|
|
# active le venv
|
|
|
|
export EDITOR=nano
|
|
|
|
|
|
# ---------------------------------------
|
|
# 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"
|
|
}
|
|
|
|
# https://github.com/zthxxx/zsh-history-enquirer
|
|
|
|
#source `npm root -g`/zsh-history-enquirer/scripts/zsh-history-enquirer.plugin.zsh
|
|
|
|
|
|
# ---------------------------------------
|
|
# 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
|
|
|
|
# zoxide
|
|
# https://github.com/ajeetdsouza/zoxide
|
|
|
|
eval "$(zoxide init --cmd j zsh)"
|
|
alias p="j -"
|
|
|
|
# thefuck
|
|
# https://github.com/nvbn/thefuck
|
|
|
|
eval $(thefuck --alias)
|
|
|
|
# dircolors
|
|
# coreutils doit être installé
|
|
|
|
eval $(gdircolors -b $HOME/.dircolors)
|
|
|
|
# tldr
|
|
#https://github.com/raylee/tldr-sh-client
|
|
|
|
complete -W "$(tldr 2>/dev/null --list)" tldr
|
|
|
|
export TLDR_HEADER='magenta bold underline'
|
|
export TLDR_QUOTE='italic'
|
|
export TLDR_DESCRIPTION='green'
|
|
export TLDR_CODE='red'
|
|
export TLDR_PARAM='blue'
|
|
|
|
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
|
|
|
|
|
|
# ---------------------------------------
|
|
# 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 | fzf'
|
|
fh() {
|
|
print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed -E 's/ *[0-9]*\*? *//' | sed -E 's/\\/\\\\/g')
|
|
}
|
|
|
|
|
|
# ---------------------------------------
|
|
# 6. Options
|
|
# ---------------------------------------
|
|
|
|
# For poetry: https://github.com/python-poetry/poetry#enable-tab-completion-for-bash-fish-or-zsh
|
|
#fpath+=~/.zfunc
|
|
# additional completions
|
|
#autoload -U +X compinit && compinit
|
|
|
|
#pipx
|
|
autoload -U bashcompinit && bashcompinit
|
|
eval "$(register-python-argcomplete pipx)"
|
|
|
|
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
|
|
|
|
# Bind CTRL+k and CTRL+j to 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'
|
|
# + récent d'abord
|
|
alias lt='gls -lAt --color'
|
|
# invisible
|
|
alias lh='gls -dla --color .*'
|
|
# --time-style="+%d-%m-%Y %H:%M"
|
|
else
|
|
cd() { builtin cd "$@" && ls -la; }
|
|
alias l='ls -la'
|
|
# + récent d'abord
|
|
alias lt='ls -lat'
|
|
# invisible
|
|
alias lh='ls -a | grep "^\."'
|
|
fi
|
|
|
|
alias l='exa -lbhgUmaFG@ --time-style=default --git --color-scale --icons'
|
|
alias ltree='exa -lbhgUma@ --time-style=default --git --color-scale --icons --tree --level=3'
|
|
|
|
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
|
|
# bzip2 xz-utils p7zip cabextract unzip
|
|
function ex () {
|
|
if [ -f $1 ] ; then
|
|
case $1 in
|
|
*.tar.bz2) tar xjf $1 ;;
|
|
*.tar.gz) tar xzf $1 ;;
|
|
*.tar.xz) tar xJf $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 ;;
|
|
*.xz) unxz $1 ;;
|
|
*.exe) cabextract $1 ;;
|
|
*) echo "'$1' ne peut etre extrait par ex()" ;;
|
|
esac
|
|
else
|
|
echo "'$1' fichier invalide"
|
|
fi
|
|
}
|
|
|
|
alias sha='shasum -a 256 '
|
|
|
|
# Créer un backup
|
|
function cpb() { cp $@{,.bak} ;}
|
|
|
|
# Extraire et supprimer
|
|
function exr {
|
|
ex $1
|
|
rm -f $1
|
|
}
|
|
|
|
# Chemin absolu
|
|
function abspath() {
|
|
if [ -d "$1" ]; then
|
|
echo "$(cd $1; pwd)"
|
|
elif [ -f "$1" ]; then
|
|
if [[ $1 == */* ]]; then
|
|
echo "$(cd ${1%/*}; pwd)/${1##*/}"
|
|
else
|
|
echo "$(pwd)/$1"
|
|
fi
|
|
fi
|
|
}
|
|
alias abspath="abspath "
|
|
|
|
# Créer un répertoire et y aller
|
|
mcd () { mkdir -p "$1" && cd "$1"; }
|
|
|
|
# go back x directories
|
|
b() {
|
|
str=""
|
|
count=0
|
|
while [ "$count" -lt "$1" ];
|
|
do
|
|
str=$str"../"
|
|
let count=count+1
|
|
done
|
|
cd $str
|
|
}
|
|
|
|
# ----------------------------
|
|
# 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.c 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.d Homebrew
|
|
# ---------------------------------------
|
|
|
|
alias bo='brew info'
|
|
alias bs='brew search'
|
|
alias bi='brew install'
|
|
alias bu='brew uninstall'
|
|
|
|
# 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.e 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.f 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.g 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'; }
|
|
|
|
alias wgetncc='wget --no-check-certificate'
|
|
function wget_archive_and_extract {
|
|
URL=$1
|
|
FILENAME=${URL##*/}
|
|
wget $URL -O $FILENAME
|
|
extract $FILENAME
|
|
rmi $FILENAME
|
|
}
|
|
alias wgetae='wget_archive_and_extract '
|
|
|
|
|
|
# ---------------------------------------
|
|
# 7.h 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.j 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.k 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'
|
|
|
|
|
|
# ---------------------------------------
|
|
# 7.l Backup (dotbare...)
|
|
# ---------------------------------------
|
|
|
|
alias dbpush='dotbare push -u mbv master'
|
|
alias dbadd='dotbare add -f $1'
|
|
alias dbcomm='dotbare commit -am $1'
|
|
alias dbback='dotbare fbackup'
|
|
|
|
|
|
# ---------------------------------------
|
|
# 8. FONCTIONS
|
|
# ---------------------------------------
|
|
|
|
# prints the path of the front Finder window. Desktop if no window open
|
|
function pwdf () {
|
|
osascript <<EOS
|
|
tell application "Finder"
|
|
if (count of Finder windows) is 0 then
|
|
set dir to (desktop as alias)
|
|
else
|
|
set dir to ((target of Finder window 1) as alias)
|
|
end if
|
|
return POSIX path of dir
|
|
end tell
|
|
EOS
|
|
}
|
|
|
|
function bbshellcheck {
|
|
shellcheck -f gcc "$@" | bbresults
|
|
}
|
|
|
|
listening() {
|
|
if [ $# -eq 0 ]; then
|
|
sudo lsof -iTCP -sTCP:LISTEN -n -P
|
|
elif [ $# -eq 1 ]; then
|
|
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1
|
|
else
|
|
echo "Usage: listening [pattern]"
|
|
fi
|
|
}
|
|
|
|
# Encrypt the given file or directory to a given recipient
|
|
function gpg-encrypt() {
|
|
if [ "$#" -ne 2 ]; then
|
|
echo "Usage: $0 FILE/DIRECTORY RECIPIENT" >&2
|
|
return 1
|
|
fi
|
|
|
|
tar -c `basename $1` | gpg --encrypt --recipient $2 -o `basename $1`.tar.gpg
|
|
}
|
|
|
|
# Decrypt the given tar.gpg file
|
|
function gpg-decrypt() {
|
|
if [ "$#" -ne 1 ] || [[ "$1" != *.tar.gpg ]]; then
|
|
echo "Usage: $0 FILE.tar.gpg" >&2
|
|
return 1
|
|
fi
|
|
|
|
gpg --quiet --decrypt $1 | tar -x
|
|
}
|
|
|
|
|
|
# ---------------------------------------
|
|
# 10. Zinit
|
|
# ---------------------------------------
|
|
|
|
|
|
### Added by Zinit's installer
|
|
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
|
|
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f"
|
|
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
|
|
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
|
|
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
|
|
print -P "%F{160}▓▒░ The clone has failed.%f%b"
|
|
fi
|
|
|
|
source "$HOME/.zinit/bin/zinit.zsh"
|
|
autoload -Uz _zinit
|
|
(( ${+_comps} )) && _comps[zinit]=_zinit
|
|
|
|
# Load a few important annexes, without Turbo
|
|
# (this is currently required for annexes)
|
|
zinit light-mode for \
|
|
zinit-zsh/z-a-rust \
|
|
zinit-zsh/z-a-as-monitor \
|
|
zinit-zsh/z-a-patch-dl \
|
|
zinit-zsh/z-a-bin-gem-node
|
|
|
|
### End of Zinit's installer chunk
|
|
|
|
# Load powerlevel10k theme
|
|
zinit ice depth"1" # git clone depth
|
|
zinit light romkatv/powerlevel10k
|
|
|
|
# Plugin history-search-multi-word loaded with investigating.
|
|
zinit load zdharma/history-search-multi-word
|
|
|
|
# Two regular plugins loaded without investigating.
|
|
zinit light zsh-users/zsh-autosuggestions
|
|
zinit light zdharma/fast-syntax-highlighting
|
|
zinit light ael-code/zsh-colored-man-pages
|
|
zinit light zsh-users/zsh-completions
|
|
zinit light marzocchi/zsh-notify
|
|
zinit light wfxr/forgit
|
|
zinit light adrieankhisbe/diractions
|
|
#
|
|
zinit ice from'gh-r' as'program'
|
|
zinit light sei40kr/fast-alias-tips-bin
|
|
zinit light sei40kr/zsh-fast-alias-tips
|
|
#
|
|
zinit light zinit-zsh/z-a-man
|
|
zinit light glostis/venv-wrapper
|
|
#zinit light mafredri/zsh-async
|
|
# ikhurramraza/bol et owenvoke/quoter-zsh incompatibles avec mafredri/zsh-async
|
|
zinit light ikhurramraza/bol
|
|
zinit light kazhala/dotbare
|
|
|
|
##zinit snippet 'https://raw.githubusercontent.com/JaumeRF/linkfile-zsh/master/linkfile-zsh.plugin.zsh'
|
|
zinit snippet 'https://raw.githubusercontent.com/gmatheu/shell-plugins/master/profile-secrets/init.zsh'
|
|
zinit snippet 'https://raw.githubusercontent.com/sineto/web-search/master/web_search.plugin.zsh'
|
|
|
|
zstyle ':notify:*' error-icon "https://media3.giphy.com/media/10ECejNtM1GyRy/200_s.gif"
|
|
zstyle ':notify:*' error-title "Command failed (in #{time_elapsed} seconds)"
|
|
zstyle ':notify:*' success-icon "https://s-media-cache-ak0.pinimg.com/564x/b5/5a/18/b55a1805f5650495a74202279036ecd2.jpg"
|
|
zstyle ':notify:*' success-title "Command finished (in #{time_elapsed} seconds)"
|
|
zstyle ':notify:*' error-sound "Glass"
|
|
zstyle ':notify:*' success-sound "default"
|
|
|
|
|
|
zstyle ":history-search-multi-word" page-size "12" # Number of entries to show (default is $LINES/3)
|
|
zstyle ":history-search-multi-word" highlight-color "fg=yellow,bold" # Color in which to highlight matched, searched text (default bg=17 on 256-color terminals)
|
|
zstyle ":plugin:history-search-multi-word" synhl "yes" # Whether to perform syntax highlighting (default true)
|
|
zstyle ":plugin:history-search-multi-word" active "bg=blue" # Effect on active history entry. Try: standout, bold, bg=blue (default underline)
|
|
zstyle ":plugin:history-search-multi-word" check-paths "yes" # Whether to check paths for existence and mark with magenta (default true)
|
|
zstyle ":plugin:history-search-multi-word" clear-on-cancel "no" # Whether pressing Ctrl-C or ESC should clear entered query
|
|
|
|
|
|
#export YSU_MESSAGE_FORMAT="$(tput setaf 1)Hey! I found this %alias_type for %command: %alias$(tput sgr0)"
|
|
|
|
export GPG_ID=bruno@clicclac.info
|
|
|
|
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
|
|
|
# Created by `pipx` on 2021-08-17 08:22:20
|
|
export PATH="$PATH:/Users/bruno/.local/bin"
|