06-02-2022

This commit is contained in:
2022-02-06 08:26:22 +01:00
parent e952582e50
commit 62fda062b9
4 changed files with 82 additions and 24 deletions

103
.zshrc
View File

@@ -20,14 +20,15 @@ export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow'
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
bindkey "ç" fzf-cd-widget
fif() {
# find-in-file - usage: fif <searchTerm> or fif "string with spaces" or fif "regex"
fif2() {
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
if [ ! "$#" -gt 0 ]; then echo "we 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;
}
@@ -48,6 +49,13 @@ PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
# poetry
export PATH="/Users/bruno/Library/Python/3.9/bin:$PATH"
# Created by `pipx` on 2021-08-17 08:22:20
export PATH="$PATH:/Users/bruno/.local/bin"
# GOBIN
#export PATH="$PATH:$HOME/go/bin"
export PATH=$PATH:$(go env GOPATH)/bin
coreutils=false
if [ -d '/opt/homebrew/opt/coreutils/libexec/gnubin' ]; then
#PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
@@ -90,28 +98,44 @@ upd_nvm() {(
# 4. Features (Z command, thefuck)
# ---------------------------------------
# Allow the use of the z plugin to easily navigate directories
# 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
# usage: j folder
# previous: p
eval "$(zoxide init --cmd j zsh)"
alias p="j -"
# diractions
# https://github.com/AdrieanKhisbe/diractions
# usage: goto folder
if [ -d "$HOME/.bookmarks" ]; then
export CDPATH=".:$HOME/.bookmarks:/"
alias goto="cd -P"
fi
# 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
@@ -123,9 +147,28 @@ export TLDR_DESCRIPTION='green'
export TLDR_CODE='red'
export TLDR_PARAM='blue'
# perl
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"
# rga
#https://github.com/phiresky/ripgrep-all
rga-fzf() {
RG_PREFIX="rga --files-with-matches"
local file
file="$(
FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \
--phony -q "$1" \
--bind "change:reload:$RG_PREFIX {q}" \
--preview-window="70%:wrap"
)" &&
echo "opening $file" &&
#xdg-open "$file"
open "$file"
}
# ---------------------------------------
# 5. History
# ---------------------------------------
@@ -190,7 +233,12 @@ zstyle ':completion:::::' completer _expand _complete _ignored _approximate # en
alias reload='source ~/.zshrc'
alias change="bbedit ~/.zshrc"
if $coreutils; then
if [ -x "$(command -v exa)" ]; then
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'
cd() { builtin cd "$@" && exa -lbhgUmaFG@ --time-style=default --git --color-scale --icons; }
elif $coreutils; then
cd() { builtin cd "$@" && gls -lA --color; }
alias l='gls -lA --color'
# + récent d'abord
@@ -207,8 +255,8 @@ else
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 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"
@@ -313,10 +361,10 @@ alias gp='git push'
alias gl='git log'
alias gs='git status'
alias gd='git diff'
alias gc='git commit -m'
alias gcm='git commit -m'
alias gca='git commit -am'
alias gb='git branch'
alias gh='git checkout'
alias gc='git checkout'
alias gra='git remote add'
alias grr='git remote rm'
alias gpu='git pull'
@@ -330,6 +378,12 @@ function acp() {
git push
}
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
#grep '"tag_name":' | # Get tag line
grep '"body":' #|
#sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# ---------------------------------------
# 7.c PYTHON
@@ -347,7 +401,7 @@ alias sonos='$HOME/Documents/venv/soco-cli/bin/soco'
# 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"
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"
@@ -360,6 +414,7 @@ alias bo='brew info'
alias bs='brew search'
alias bi='brew install'
alias bu='brew uninstall'
alias bk='$HOME/.kymsu/plugins.d/homebrew.sh'
# brew restart apache
alias bra='brew services restart httpd'
@@ -396,7 +451,9 @@ alias nextcloud='cd $HOME/Nextcloud'
# 7.f SEARCHING
# ---------------------------
alias qfind="find / -name " # qfind: Quickly search for file
alias qfind="find / 2>/dev/null -name " # qfind: Quickly search for file
alias find="find / 2>/dev/null "
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
@@ -572,6 +629,8 @@ alias mailoptimiser="curl -sS https://raw.githubusercontent.com/pbihq/tools/mast
# Multitail
alias mt='multitail -F /usr/local/etc/multitail.conf'
# Convert video to Plex AppleTV
alias atv="$HOME/.local/bin/convert-videos-for-plex.sh -fr"
# ---------------------------------------
# 7.l Backup (dotbare...)
@@ -640,12 +699,11 @@ function gpg-decrypt() {
# 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"
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/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" && \
command git clone https://github.com/zdharma-continuum/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
@@ -657,10 +715,10 @@ autoload -Uz _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
zdharma-continuum/z-a-rust \
zdharma-continuum/z-a-as-monitor \
zdharma-continuum/z-a-patch-dl \
zdharma-continuum/z-a-bin-gem-node
### End of Zinit's installer chunk
@@ -669,11 +727,11 @@ 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
zinit load zdharma-continuum/history-search-multi-word
# Two regular plugins loaded without investigating.
zinit light zsh-users/zsh-autosuggestions
zinit light zdharma/fast-syntax-highlighting
zinit light zdharma-continuum/fast-syntax-highlighting
zinit light ael-code/zsh-colored-man-pages
zinit light zsh-users/zsh-completions
zinit light marzocchi/zsh-notify
@@ -684,7 +742,7 @@ 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 zdharma-continuum/z-a-man
zinit light glostis/venv-wrapper
#zinit light mafredri/zsh-async
# ikhurramraza/bol et owenvoke/quoter-zsh incompatibles avec mafredri/zsh-async
@@ -717,6 +775,3 @@ 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"