1
0
This commit is contained in:
Jeff Lance 2024-02-05 23:28:28 +01:00
parent 16253c1cbe
commit b9508955be
22 changed files with 488 additions and 0 deletions

View File

@ -0,0 +1,2 @@
fpath+="${0:h}/src"

View File

@ -0,0 +1,129 @@
#compdef alacritty
autoload -U is-at-least
_alacritty() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'--embed=[Defines the X11 window ID (as a decimal integer) to embed Alacritty within]:EMBED: ' \
'--config-file=[Specify alternative configuration file \[default: $XDG_CONFIG_HOME/alacritty/alacritty.yml\]]:CONFIG_FILE: ' \
'--socket=[Path for IPC socket creation]:SOCKET: ' \
'*-o+[Override configuration file options \[example: cursor.style=Beam\]]:OPTION: ' \
'*--option=[Override configuration file options \[example: cursor.style=Beam\]]:OPTION: ' \
'--working-directory=[Start the shell in the specified working directory]:WORKING_DIRECTORY: ' \
'*-e+[Command and args to execute (must be last argument)]:COMMAND: ' \
'*--command=[Command and args to execute (must be last argument)]:COMMAND: ' \
'-t+[Defines the window title \[default: Alacritty\]]:TITLE: ' \
'--title=[Defines the window title \[default: Alacritty\]]:TITLE: ' \
'--class=[Defines window class/app_id on X11/Wayland \[default: Alacritty\]]:instance> | <instance>,<general: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'--print-events[Print all events to stdout]' \
'--ref-test[Generates ref test]' \
'(-v)*-q[Reduces the level of verbosity (the min level is -qq)]' \
'(-q)*-v[Increases the level of verbosity (the max level is -vvv)]' \
'--hold[Remain open after child process exit]' \
":: :_alacritty_commands" \
"*::: :->alacritty" \
&& ret=0
case $state in
(alacritty)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:alacritty-command-$line[1]:"
case $line[1] in
(msg)
_arguments "${_arguments_options[@]}" \
'-s+[IPC socket connection path override]:SOCKET: ' \
'--socket=[IPC socket connection path override]:SOCKET: ' \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_alacritty__msg_commands" \
"*::: :->msg" \
&& ret=0
case $state in
(msg)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:alacritty-msg-command-$line[1]:"
case $line[1] in
(create-window)
_arguments "${_arguments_options[@]}" \
'--working-directory=[Start the shell in the specified working directory]:WORKING_DIRECTORY: ' \
'*-e+[Command and args to execute (must be last argument)]:COMMAND: ' \
'*--command=[Command and args to execute (must be last argument)]:COMMAND: ' \
'-t+[Defines the window title \[default: Alacritty\]]:TITLE: ' \
'--title=[Defines the window title \[default: Alacritty\]]:TITLE: ' \
'--class=[Defines window class/app_id on X11/Wayland \[default: Alacritty\]]:instance> | <instance>,<general: ' \
'--version[Print version information]' \
'--hold[Remain open after child process exit]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'--version[Print version information]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
esac
;;
esac
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
esac
;;
esac
}
(( $+functions[_alacritty_commands] )) ||
_alacritty_commands() {
local commands; commands=(
'msg:Send a message to the Alacritty socket' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'alacritty commands' commands "$@"
}
(( $+functions[_alacritty__msg__create-window_commands] )) ||
_alacritty__msg__create-window_commands() {
local commands; commands=()
_describe -t commands 'alacritty msg create-window commands' commands "$@"
}
(( $+functions[_alacritty__help_commands] )) ||
_alacritty__help_commands() {
local commands; commands=()
_describe -t commands 'alacritty help commands' commands "$@"
}
(( $+functions[_alacritty__msg__help_commands] )) ||
_alacritty__msg__help_commands() {
local commands; commands=()
_describe -t commands 'alacritty msg help commands' commands "$@"
}
(( $+functions[_alacritty__msg_commands] )) ||
_alacritty__msg_commands() {
local commands; commands=(
'create-window:Create a new window in the same Alacritty process' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'alacritty msg commands' commands "$@"
}
_alacritty "$@"

View File

@ -0,0 +1,2 @@
fpath+="${0:h}/src"

View File

@ -0,0 +1,53 @@
#compdef buku
#
# Completion definition for buku.
#
# Author:
# Arun Prakash Jana <engineerarun@gmail.com>
#
setopt localoptions noshwordsplit noksharrays
local -a args
args=(
'(-a --add)'{-a,--add}'[add bookmark]:URL tags'
'(--ai)--ai[auto-import bookmarks]'
'(-c --comment)'{-c,--comment}'[comment on bookmark]'
'(--cached)--cached[visit Wayback Machine cached version]:index/url'
'(--colors)--colors[set output colors in 5-letter string]:color string'
'(-d --delete)'{-d,--delete}'[delete bookmark]'
'(--deep)--deep[search matching substrings]'
'(-e --export)'{-e,--export}'[export bookmarks]:html/md/db output file'
'(--expand)--expand[expand a tny.im shortened URL]:index/shorturl'
'(-f --format)'{-f,--format}'[limit fields in print and JSON output]:value'
'(-h --help)'{-h,--help}'[show help]'
'(-i --import)'{-i,--import}'[import bookmarks]:html/md/db input file'
'(--immutable)--immutable[disable title update from web]:value'
'(-j --json)'{-j,--json}'[show JSON output for print and search]:file'
'(-k --unlock)'{-k,--unlock}'[decrypt database]'
'(-l --lock)'{-l,--lock}'[encrypt database]'
'(-n --count)'{-n,--count}'[results per page]:value'
'(--nc)--nc[disable color output]'
'(--np)--np[noninteractive mode]'
'(-o --open)'{-o,--open}'[open bookmarks in browser]'
'(--oa)--oa[browse all search results immediately]'
'(-p --print)'{-p,--print}'[show bookmark details]'
'(-r --sreg)'{-r,--sreg}'[match a regular exression]:regex'
'(--replace)--replace[replace a tag]:tag to replace'
'(-s --sany)'{-s,--sany}'[match any keyword]:keyword(s)'
'(-s --sall)'{-s,--sall}'[match all keywords]:keyword(s)'
'(--shorten)--shorten[shorten a URL using tny.im]:index/url'
'(--suggest)--suggest[show a list of similar tags]'
'(-t --stag)'{-t,--stag}'[search by tag or show tags]'
'(--tacit)--tacit[reduce verbosity]'
'(--tag)--tag[set tags, use + to append, - to remove]'
'(--threads)--threads[max connections for full refresh]:value'
'(--title)--title[set custom title]'
'(-u --update)'{-u,--update}'[update bookmark]'
'(--url)--url[set url]:url'
'(-V)-V[check latest upstream release]'
'(-v --version)'{-v,--version}'[show program version]'
'(-w --write)'{-w,--write}'[open editor]'
'(-x --exclude)'{-x,--exclude}'[exclude keywords]:keyword(s)'
'(-g --debug)'{-g,--debug}'[enable debugging mode]'
)
_arguments -S -s $args

View File

@ -0,0 +1,3 @@
debian
=======

View File

@ -0,0 +1 @@
wget -q -O - "${1}" | sudo apt-key add -

View File

@ -0,0 +1,7 @@
# List packages by size
function apt-list-packages() {
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
grep -v deinstall | \
sort -n | \
awk '{print $1" "$2}'
}

View File

@ -0,0 +1,45 @@
#
# Debian Shortcuts and Aliases
#
#
# Common Operations
#
alias acs='apt-cache search' # search through apt software package
# cache
alias aps='apt search' # search through packages list
alias acS='apt-cache show' # show info about a package
alias afs='apt-file search' # search file in packages
alias ags='apt-get source' # fetch source packages through apt-get
alias acp='apt-cache policy' # displays priority of package sources
alias alp='apt-list-packages' # list packages by size
alias aka='apt-key-add' # retrieve and add key to keyring
alias alu="apt list --upgradable" # list upgradable packages
#
# Superuser apt-get Operations
#
alias aga='sudo apt-get autoremove' # autoremove unecessary packages
alias agu='sudo apt-get update' # update packages database
alias agU='sudo apt-get upgrade' # upgrade packages
alias agd='sudo apt-get dist-upgrade' # upgrade dist
alias agc='sudo apt-get clean' # clears out the local repository of
# retrieved package files except lock
# files
alias agi='sudo apt-get install' # install package
alias agp='sudo apt-get purge' # Removes packages along with
# configuration files
alias agr='sudo apt-get remove' # Removes packages, keeps the
# configuration files
alias aguu='agu && agU'
#
# Superuser dpkg Operations
#
alias di='sudo dpkg -i' # install local .deb file

View File

@ -0,0 +1,3 @@
jl-helper
=======

View File

@ -0,0 +1,5 @@
cpv() {
rsync -pogbr -hhh --backup-dir=/tmp/rsync -e /dev/null --progress "$@"
}
compdef _files cpv

View File

@ -0,0 +1,9 @@
# vim:et sts=2 sw=2 ft=zsh
#
# Display ip of the docker container passed as arg
#
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${1}
compdef _files dip

View File

@ -0,0 +1,10 @@
# vim:et sts=2 sw=2 ft=zsh
#
# Get .gitignore from distant api
#
function gi() {
curl -sLw "\n" https://www.toptal.com/developers/gitignore/api/"$@" ;
}
compdef _files gi

View File

@ -0,0 +1,23 @@
# vim:et sts=2 sw=2 ft=zsh
#
# Display public ip information
#
URL="ipinfo.io?token=$(pass _api_keys/ipinfo_perso-0)"
case "${1}" in
(-a)
curl --silent -L ${URL} > /dev/null | jq ;;
(-c)
curl --silent -L ${URL} > /dev/null | jq '.city';;
(-C)
curl --silent -L ${URL} > /dev/null | jq '.country';;
(-i)
curl --silent -L ${URL} > /dev/null | jq '.ip';;
(-r)
curl --silent -L ${URL} > /dev/null | jq '.region';;
(*)
curl --silent -L ${URL} > /dev/null | jq ;;
esac
compdef _files gip

View File

@ -0,0 +1,6 @@
shrinkpdf() {
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$(basename -s .pdf ${1})_shrink.pdf" "${1}"
}
compdef _files shrinkpdf

View File

@ -0,0 +1,12 @@
update_auth_sock() {
local socket_path="$(tmux show-environment | sed -n 's/^SSH_AUTH_SOCK=//p')"
if ! [[ "$socket_path" ]]; then
echo 'no socket path' >&2
return 1
else
export SSH_AUTH_SOCK="$socket_path"
fi
}
compdef _files update_auth_sock

View File

@ -0,0 +1,62 @@
#
# Personal aliases
#
#
# Admin
#
alias udvrld='sudo udevadm control --reload-rules && sudo udevadm trigger'
#
# Editors
#
alias vim='lvim' # redirect vim to nvim
#
# Mail, internet
#
alias mutt='neomutt -f ${HOME}/Mail/jeff.lance@mala.fr/inbox/'
alias neomutt='neomutt -f ${HOME}/Mail/jeff.lance@mala.fr/inbox/'
#
# Utilities
#
alias ip='ip -c' # ip address
# alias ls='lsd' # pretty ls
alias md='mkdir -p' # mkdir alias
alias open='xdg-open' # open files
alias pips='pip_search' # pip search tool
alias rs='rsync -Pavzl' # rsync shortcut
alias t='tmux' # tmux
alias ta='t a -t' # tmux attach to a session
alias tls='t ls' # tmux list sessions
alias tn='t n -t' # tmux new session
alias tvs='transcode-video --scan' #
alias xcolor='xcolor | xclip -i' # xcolor
alias yd='yt-dlp' # yt-dlp best download
#
# Shortcuts
#
hash -d crs="${HOME}/Cours" # cours
hash -d doc="${HOME}/Documents" # documents
hash -d dot="${HOME}/dotfiles" # dotfiles
#
# Environment
#
# interactive comments
setopt interactivecomments
bindkey '^R' history-incremental-search-backward

View File

@ -0,0 +1,3 @@
debian
=======

View File

@ -0,0 +1,47 @@
#!/bin/zsh
# File : init.zsh
# Author : Jeff LANCE <email@jefflance.me>
# Date : 03.03.2021
# Last Modified Date: 27.06.2021
# Last Modified By : Jeff LANCE <email@jefflance.me>
#
# Manjaro Shortcuts and Aliases
#
#
# pamac Operations
#
alias pamss='pamac search' # search through package repositories
alias pamsi='pamac info' # show info about a package
alias pamud='pamac update' # update packages database
alias pamug='pamac upgrade' # upgrade packages
alias pamin='pamac install' # install package
alias pamrm='pamac remove' # remove package
alias pamdg='pamud && pamug'
alias pamro='pamrm -o' # remove orphan packages
#
# pacman Operations
#
alias pacss='pacman -Ss' # search through package repositories
alias pacsi='pacman -Si' # display info about a package in the repositories
alias pacud='sudo pacman -Sy' # update & refresh local package db
alias pacug='sudo pacman -Syu' # sync with repositories before upgrading packages
alias pacin='sudo pacman -Syu' # update and install package from repositories
alias pacrm='sudo pacman -R' # remove package, keeping settings and depedencies
alias pacRm='sudo pacman -Rns' # remove package with its settings and depedencies
alias paclo='sudo pacman -Qdt' # list orphans
alias pacro='sudo pacman -Rs $(pacman -Qdt)' # remove orphans
alias pacow='pacman -Qo' # show which package own a file
#
# pkgfile Operations
#
alias pasf='pkgfile' # search file in packages

View File

@ -0,0 +1,34 @@
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
# Save beginning space
local WHITESPACE=""
if [[ ${LBUFFER:0:1} == " " ]] ; then
WHITESPACE=" "
LBUFFER="${LBUFFER:1}"
fi
if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then
if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then
RBUFFER=" ${BUFFER#$EDITOR }"
LBUFFER="sudoedit"
else
LBUFFER="sudoedit ${LBUFFER#$EDITOR }"
fi
elif [[ $BUFFER == sudoedit\ * ]]; then
if [[ ${#LBUFFER} -le 8 ]]; then
RBUFFER=" ${BUFFER#sudoedit }"
LBUFFER="$EDITOR"
else
LBUFFER="$EDITOR ${LBUFFER#sudoedit }"
fi
elif [[ $BUFFER == sudo\ * ]]; then
if [[ ${#LBUFFER} -le 4 ]]; then
RBUFFER="${BUFFER#sudo }"
LBUFFER=""
else
LBUFFER="${LBUFFER#sudo }"
fi
else
LBUFFER="sudo $LBUFFER"
fi

View File

@ -0,0 +1,6 @@
zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
bindkey -M emacs '\e\e' sudo-command-line
bindkey -M vicmd '\e\e' sudo-command-line
bindkey -M viins '\e\e' sudo-command-line

View File

@ -0,0 +1,25 @@
zimfw() { source /home/jeff/.zim/zimfw.zsh "${@}" }
zmodule() { source /home/jeff/.zim/zimfw.zsh "${@}" }
fpath=(/home/jeff/.zim/modules/git/functions /home/jeff/.zim/modules/archive/functions /home/jeff/dotfiles/conf.d/zim/modules/jl-helper/functions /home/jeff/dotfiles/conf.d/zim/modules/sudo/functions /home/jeff/.zim/modules/zsh-kitty/functions /home/jeff/.zim/modules/utility/functions /home/jeff/.zim/modules/git-info/functions /home/jeff/.zim/modules/zim-starship/functions ${fpath})
autoload -Uz -- git-alias-lookup git-branch-current git-branch-delete-interactive git-branch-remote-tracking git-dir git-ignore-add git-root git-stash-clear-interactive git-stash-recover git-submodule-move git-submodule-remove archive lsarchive unarchive cpv dip gi gip shrinkpdf update_auth_sock sudo-command-line mkcd mkpw coalesce git-action git-info
source /home/jeff/.zim/modules/environment/init.zsh
source /home/jeff/.zim/modules/input/init.zsh
source /home/jeff/.zim/modules/zsh-completions/zsh-completions.plugin.zsh
source /home/jeff/dotfiles/conf.d/zim/modules/buku/init.zsh
source /home/jeff/.zim/modules/completion/init.zsh
source /home/jeff/.zim/modules/zsh-autosuggestions/zsh-autosuggestions.zsh
source /home/jeff/.zim/modules/git/init.zsh
source /home/jeff/.zim/modules/termtitle/init.zsh
source /home/jeff/.zim/modules/archive/init.zsh
source /home/jeff/dotfiles/conf.d/zim/modules/manjaro/init.zsh
source /home/jeff/dotfiles/conf.d/zim/modules/jl-helper/init.zsh
source /home/jeff/dotfiles/conf.d/zim/modules/sudo/init.zsh
source /home/jeff/.zim/modules/z/z.sh
source /home/jeff/.zim/modules/zsh-kitty/zsh-kitty.plugin.zsh
source /home/jeff/.zim/modules/utility/init.zsh
source /home/jeff/.zim/modules/exa/init.zsh
source /home/jeff/.zim/modules/fzf/init.zsh
source /home/jeff/.zim/modules/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /home/jeff/.zim/modules/zsh-history-substring-search/zsh-history-substring-search.zsh
source /home/jeff/.zim/modules/steeef/steeef.zsh-theme
source /home/jeff/.zim/modules/zim-starship/init.zsh

View File

@ -0,0 +1 @@
# Do nothing. This file is deprecated.