Bash: please completion

This commit is contained in:
Akemi Izuko 2024-07-17 17:19:07 -06:00
parent a8c315f5b4
commit 2a583f1920
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC
3 changed files with 36 additions and 0 deletions

View file

@ -33,7 +33,9 @@ alias ra='rg --no-ignore -.'
alias ee='exit'
alias ffprobe='ffprobe -hide_banner'
alias shm='cd /dev/shm'
alias avada-kedavra='kill -9'
alias ip='ip -color'
alias ip6='ip -color -6'
# ===================================================================

View file

@ -282,6 +282,17 @@ function bless () {
}
# Attach to tmux session ============================================
function _ta() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(tmux ls | awk 'match($0, /^[^:]*: /) { print substr($0, RSTART, RLENGTH-2) }')
COMPREPLY+=( $(compgen -W "$opts" -- ${cur}) )
return 0
}
function ta() {
if [[ -n "$1" ]]; then
tmux new -As "$1"
@ -295,6 +306,8 @@ function ta() {
fi
}
complete -F _ta ta
# Image magick ======================================================
function magika() {
if [[ "$1" == "a" || "$1" == "av1" ]]; then
@ -354,4 +367,24 @@ rooter() {
return 1
}
# Completion for please =============================================
_please() {
local cur prev words cword
_init_completion || return
# Complete command in first argument position
if [ $cword -eq 1 ]; then
COMPREPLY=($(compgen -c -- "$cur"))
return 0
fi
# Remove first word (please)
words=("${words[@]:1}")
(( cword-- ))
# Run the completion for the command after 'please'
_command_offset 1
}
complete -F _please please
# vim: set ft=bash ff=unix:

View file

@ -13,6 +13,7 @@ source_completion_scripts () {
if [[ "$(type -t _fzf_setup_completion)" == 'function' ]]; then
_fzf_setup_completion path mpv vi vii nvim vimiv cat
_fzf_setup_completion proc avada-kedavra
fi
}