diff --git a/dotfiles/.local/share/bash-completion/completions/fzf.bash b/dotfiles/.local/share/bash-completion/completions/fzf.bash index bfcacd4a..58adccc7 100644 --- a/dotfiles/.local/share/bash-completion/completions/fzf.bash +++ b/dotfiles/.local/share/bash-completion/completions/fzf.bash @@ -354,4 +354,4 @@ _fzf_setup_completion 'var' export unset _fzf_setup_completion 'alias' unalias _fzf_setup_completion 'host' ssh telnet _fzf_setup_completion 'proc' kill -fi \ No newline at end of file +fi diff --git a/dotfiles/.local/share/bash-completion/completions/googler-at.bash b/dotfiles/.local/share/bash-completion/completions/googler-at.bash deleted file mode 100644 index 491a6490..00000000 --- a/dotfiles/.local/share/bash-completion/completions/googler-at.bash +++ /dev/null @@ -1,330 +0,0 @@ -# googler @t alias list -# Author: Arun Prakash Jana -# email: engineerarun@gmail.com -# -# To request key addition or removal upstream, please drop an email. - - # A - -# Amazon.com - alias @a='googler -w amazon.com' -# AlternativeTo - alias @alt='googler -w alternativeto.net' -# Android Developers - alias @android='googler -w developer.android.com' -# ARM Information Center - alias @arm='googler -w infocenter.arm.com' -# asciinema - alias @asciinema='googler -w asciinema.org' -# Ask Ubuntu - alias @askubuntu='googler -w askubuntu.com' -# Arch Forums - alias @abbs='googler -w bbs.archlinux.org' -# Arch User Repository - alias @aur='googler -w aur.archlinux.org' -# Arch Wiki - alias @aw='googler -w wiki.archlinux.org' -# AZLyrics - alias @azl='googler -w azlyrics.com' - - # B - -# BBC - alias @bbc='googler -w bbc.co.uk' -# Encyclopaedia Britannica - alias @britannica='googler -w britannica.com' - - # C - -# crunchbase - alias @cb='googler -w crunchbase.com' -# Chrome Extensions - alias @chrome='googler -w chrome.google.com' -# craigslist - alias @cl='googler -w craigslist.org' -# commandlinefu - alias @cmd='googler -w commandlinefu.com' -# CNN - alias @cnn='googler -w cnn.com' -# Comedy Central - alias @comedy='googler -w cc.com' -# CPP Reference - alias @cpp='googler -w en.cppreference.com' -# Cracked.com - alias @cracked='googler -w cracked.com' -# Cricinfo - alias @cricinfo='googler -w espncricinfo.com' - - # D - -# The Free Dictionary - alias @d='googler -w thefreedictionary.com' -# Dictionary.com - alias @di='googler -w dictionary.com' -# DistroWatch - alias @distrowatch='googler -w distrowatch.com' -# Daily Natural Remedies - alias @dnr='googler -w dailynaturalremedies.com' -# Debian Package Search - alias @dpkg='googler -w packages.debian.org' - - # E - -# eBay - alias @e='googler -w ebay.com' -# Episode Guides - alias @eg='googler -w epguides.com' -# Embedded - alias @embedded='googler -w embedded.com' -# ESPN - alias @espn='googler -w espn.com' -# Etsy - alias @etsy='googler -w etsy.com' -# Online Etymology Dictionary - alias @etym='googler -w etymonline.com' - - # F - -# Facebook - alias @fb='googler -w facebook.com' -# Fandango Movie Reviews - alias @fd='googler -w fandango.com' -# Firefox Add-ons - alias @firefox='googler -w addons.mozilla.org' -# Forbes - alias @forbes='googler -w forbes.com' -# Forvo - alias @forvo='googler -w forvo.com' -# Financial Times - alias @ft='googler -w markets.ft.com' - - # G - -# Google Search - alias @g='googler' -# Genius Lyrics - alias @genius='googler -w genius.com' -# GitHub - alias @gh='googler -w github.com' -# GNU - alias @gnu='googler -w gnu.org' -# The GNU Privacy Guard - alias @gpg='googler -w gnupg.org' -# Project Gutenberg - alias @gutenberg='googler -w gutenberg.org' - - # H - -# Hackaday - alias @had='googler -w hackaday.com' -# Healthline - alias @hl='googler -w healthline.com' -# History - alias @history='googler -w history.com' -# Hacker News - alias @hn='googler -w news.ycombinator.com' -# HowStuffWorks - alias @hsw='googler -w howstuffworks.com' -# HowtoForge - alias @htf='googler -w howtoforge.com' -# Hulu - alias @hulu='googler -w hulu.com' - - # I - -# IEEE - alias @ieee='googler -w ieee.org' -# IETF - alias @ietf='googler -w ietf.org' -# IETF Datatracker - alias @ietfd='googler -w datatracker.ietf.org' -# Instagram - alias @ig='googler -w instagram.com' -# IMDB - alias @imdb='googler -w imdb.com' -# Internet Radio - alias @iradio='googler -w internet-radio.com' - - # J - - # K - -# The Linux Kernel Archives - alias @kernel='googler -w kernel.org' -# Khan Academy - alias @khan='googler -w khanacademy.org' - - # L - -# Last.fm - alias @lfm='googler -w last.fm' -# LinkedIn - alias @li='googler -w linkedin.com' -# Linux.com - alias @linux='googler -w linux.com' -# Linux Journal - alias @lj='googler -w linuxjournal.com' -# LinuxQuestions - alias @lq='googler -w linuxquestions.org' -# LQWiki - alias @lqw='googler -w wiki.linuxquestions.org' -# LWN.net - alias @lwn='googler -w lwn.net' -# Linux Cross Reference - alias @lxr='googler -w lxr.free-electrons.com' - - # M - -# Ubuntu Manpage - alias @man='googler -w manpages.ubuntu.com' -# Linux manual page - alias @man7='googler -w man7.org' -# Manga Reader - alias @mangar='googler -w mangareader.net' -# MLB - alias @mlb='googler -w mlb.mlb.com' -# Mac Rumors - alias @mr='googler -w macrumors.com' - - # N - -# Google News - alias @n='googler -N' -# Nature Research - alias @nature='googler -N nature.com' -# NBA - alias @nba='googler -N nba.com' -# National Geographic - alias @ng='googler -N nationalgeographic.com' -# National Programme on Technology Enhanced Learning - alias @nptel='googler -w nptel.ac.in' - - # O - -# MIT OpenCourseWare - alias @ocw='googler -w ocw.mit.edu' -# Open Embedded - alias @oembedded='googler -w openembedded.org' -# OpenSubtitles - alias @op='googler -w opensubtitles.org' -# Opensource.com - alias @opensource='googler -w opensource.com' -# Open Source Alternative - alias @osalt='googler -w osalt.com' -# OSDev Wiki - alias @osdev='googler -w wiki.osdev.org' -# OpenWrt - alias @owrt='googler -w openwrt.org' -# Oxford Dictionary - alias @ox='googler -w en.oxforddictionaries.com' - - # P - -# Google Patents - alias @patent='googler -w patents.google.com' -# The Pirate Bay - alias @pirate='googler -w thepiratebay.org' -# Android Apps - alias @play='googler -w play.google.com' -# PlayOnLinux - alias @playonlinux='googler -w playonlinux.com' -# Python documentation - alias @python='googler -w docs.python.org' - - # Q - -# Wikiquote - alias @quotes='googler -w en.wikiquote.org' - - # R - -# Reddit - alias @r='googler -w reddit.com' -# Reader's Digest - alias @rd='googler -w rd.com' -# RFC Reader - alias @rfc='googler -w rfc-editor.org' -# Rpmfind - alias @rpm='googler -w rpmfind.net' -# Rotten Tomatoes - alias @rt='googler -w rottentomatoes.com' - - # S - -# OnlineSlangDictionary - alias @slang='googler -w onlineslangdictionary.com' -# Stack Overflow - alias @so='googler -w stackoverflow.com' -# Softpedia - alias @softpedia='googler -w softpedia.com' -# SurceForge - alias @sourceforge='googler -w sourceforge.net' -# Subscene - alias @ss='googler -w subscene.com' -# Steam - alias @st='googler -w store.steampowered.com' - - # T - -# Thesaurus.com - alias @t='googler -w thesaurus.com' -# TED Talks - alias @ted='googler -w ted.com' -# The Linux Documentation Project - alias @tldp='googler -w tldp.org' -# tl;drLegal - alias @tldrlegal='googler -w tldrlegal.com' -# Torrentz2 - alias @to='googler -w torrentz2.eu' -# The Pirate Bay - alias @tpb='googler -w thepiratebay.org' -# TuneIn - alias @tunein='googler -w tunein.com' -# Twitter - alias @tw='googler -w twitter.com' -# Twitch - alias @twitch='googler -w twitch.tv' - - # U - -# Ubuntu Forums - alias @ubuntuforums='googler -w ubuntuforums.org' -# Ubuntu Packages - alias @ubuntupackages='googler -w packages.ubuntu.com' -# Ubuntu Wiki - alias @uwiki='googler -w wiki.ubuntu.com' - - # V - -# Vim Wiki - alias @vim='googler -w vim.org' - - # W - -# Wikipedia - alias @w='googler -w en.wikipedia.org' -# Walmart - alias @walmart='googler -w walmart.com' -# Weather.com - alias @weather='googler -w weather.com' -# Wikia - alias @wikia='googler -w wikia.com' - - # X - -# XKCD - alias @xkcd='googler -w xkcd.com' - - # Y - -# Yahoo - alias @y='googler -w yahoo.com' -# Yahoo Finance - alias @yf='googler -w finance.yahoo.com' -# YouTube - alias @yt='googler -w youtube.com' - - # Z - -# ZDNet - alias @zdnet='googler -w zdnet.com' diff --git a/dotfiles/.local/share/bash-completion/completions/wp.bash b/dotfiles/.local/share/bash-completion/completions/wp.bash new file mode 100644 index 00000000..9df572b6 --- /dev/null +++ b/dotfiles/.local/share/bash-completion/completions/wp.bash @@ -0,0 +1,23 @@ +# bash completion for the `wp` command + +_wp_complete() { + local OLD_IFS="$IFS" + local cur=${COMP_WORDS[COMP_CWORD]} + + IFS=$'\n'; # want to preserve spaces at the end + local opts="$(wp cli completions --line="$COMP_LINE" --point="$COMP_POINT")" + + if [[ "$opts" =~ \\s* ]] + then + COMPREPLY=( $(compgen -f -- $cur) ) + elif [[ $opts = "" ]] + then + COMPREPLY=( $(compgen -f -- $cur) ) + else + COMPREPLY=( ${opts[*]} ) + fi + + IFS="$OLD_IFS" + return 0 +} +complete -o nospace -F _wp_complete wp diff --git a/dotfiles/.local/share/bash-completion/generate.sh b/dotfiles/.local/share/bash-completion/generate.sh index cfef3160..45a60810 100644 --- a/dotfiles/.local/share/bash-completion/generate.sh +++ b/dotfiles/.local/share/bash-completion/generate.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash ### Initialize -COMPLETION_DIR="$XDG_DATA_HOME/bash-completion/completions" +COMPLETION_DIR="$HOME/.local/share/bash-completion/completions" mkdir -p "$COMPLETION_DIR" FALLBACK_URL="https://gitlab.com/megabyte-labs/misc/dotfiles/-/raw/master/dotfiles/.local/share/bash-completion/completions" @@ -35,6 +35,18 @@ elif [ -f "$COMPLETION_DIR/fig.bash" ]; then rm "$COMPLETION_DIR/fig.bash" fi +### fzf +if command -v fzf > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix fzf)/shell/completion.bash" ]; then + cp "$(brew --prefix fzf)/shell/completion.bash" "$COMPLETION_DIR/fzf.bash" + cp "$(brew --prefix fzf)/shell/key-bindings.bash" "$COMPLETION_DIR/fzf-key-bindings.bash" +elif command -v fzf > /dev/null; then + curl -sSL "$FALLBACK_URL/fzf.bash" > "$COMPLETION_DIR/fzf.bash" + curl -sSL "$FALLBACK_URL/fzf-key-bindings.bash" > "$COMPLETION_DIR/fzf-key-bindings.bash" +elif [ -f "$COMPLETION_DIR/fzf.bash" ]; then + rm "$COMPLETION_DIR/fzf.bash" + rm "$COMPLETION_DIR/fzf-key-bindings.bash" +fi + ### gh if command -v gh > /dev/null; then gh completion -s bash > "$COMPLETION_DIR/gh.bash" @@ -43,10 +55,10 @@ elif [ -f "$COMPLETION_DIR/gh.bash" ]; then fi ### Google Cloud SDK -if command -v gcloud > /dev/null && command -v brew > /dev/null; then - if [ -f "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" ]; then - cat "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" > "$COMPLETION_DIR/google-cloud-sdk.bash" - elif command -v +if command -v gcloud > /dev/null; then + curl -sSL "$FALLBACK_URL/gcloud.bash" > "COMPLETION_DIR/gcloud.bash" +elif [ -f "$COMPLETION_DIR/gcloud.bash" ]; then + rm "$COMPLETION_DIR/gcloud.bash" fi ### Googler @@ -61,54 +73,90 @@ fi ### Gradle if command -v gradle > /dev/null; then curl -sSL https://raw.githubusercontent.com/eriwen/gradle-completion/master/gradle-completion.bash > "$COMPLETION_DIR/gradle.bash" +elif [ -f "$COMPLETION_DIR/gradle.bash" ]; then + rm "$COMPLETION_DIR/gradle.bash" fi ### Helm if command -v helm > /dev/null; then helm completion bash > "$COMPLETION_DIR/helm.bash" +elif [ -f "$COMPLETION_DIR/helm.bash" ]; then + rm "$COMPLETION_DIR/helm.bash" fi ### Hyperfine if command -v hyperfine > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix hyperfine)/etc/bash_completion.d/hyperfine.bash" ]; then cp "$(brew --prefix hyperfine)/etc/bash_completion.d/hyperfine.bash" "$COMPLETION_DIR/hyperfine.bash" elif command -v hyperfine > /dev/null; then - + curl -sSL "$FALLBACK_URL/hyperfine.bash" > "$COMPLETION_DIR/hyperfine.bash" +elif [ -f "$COMPLETION_DIR/hyperfine.bash" ]; then + rm "$COMPLETION_DIR/hyperfine.bash" fi ### kubectl if command -v kubectl > /dev/null; then kubectl completion bash > "$COMPLETION_DIR/kubectl.bash" +elif [ -f "$COMPLETION_DIR/kubectl.bash" ]; then + rm "$COMPLETION_DIR/kubectl.bash" fi ### mcfly export MCFLY_KEY_SCHEME=vim if command -v mcfly > /dev/null; then mcfly init bash > "$COMPLETION_DIR/mcfly.bash" +elif [ -f "$COMPLETION_DIR/mcfly.bash" ]; then + rm "$COMPLETION_DIR/mcfly.bash" +fi + +### nb +if command -v nb > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix nb)/etc/bash_completion.d/nb.bash" ]; then + cp "$(brew --prefix nb)/etc/bash_completion.d/nb.bash" "$COMPLETION_DIR/nb.bash" +elif command -v nb > /dev/null; then + curl -sSL "$FALLBACK_URL/nb.bash" > "$COMPLETION_DIR/nb.bash" +elif [ -f "$COMPLETION_DIR/nb.bash" ]; then + rm "$COMPLETION_DIR/nb.bash" +fi + +### nnn +if command -v nnn > /dev/null && command -v brew > /dev/null && [ -f "$(brew --prefix nnn)/etc/bash_completion.d/nnn-completion.bash" ]; then + cp "$(brew --prefix nnn)/etc/bash_completion.d/nnn-completion.bash" "$COMPLETION_DIR/nnn.bash" +elif command -v nnn > /dev/null; then + curl -sSL "$FALLBACK_URL/nnn.bash" > "$COMPLETION_DIR/nnn.bash" +elif [ -f "$COMPLETION_DIR/nnn.bash" ]; then + rm "$COMPLETION_DIR/nnn.bash" fi ### npm if command -v npm > /dev/null; then npm completion > "$COMPLETION_DIR/npm.bash" +elif [ -f "$COMPLETION_DIR/npm.bash" ]; then + rm "$COMPLETION_DIR/npm.bash" fi ### Poetry if command -v poetry > /dev/null; then poetry completions bash > "$COMPLETION_DIR/poetry.bash" +elif [ -f "$COMPLETION_DIR/poetry.bash" ]; then + rm "$COMPLETION_DIR/poetry.bash" fi ### Volta if command -v volta > /dev/null; then volta completions bash > "$COMPLETION_DIR/volta.bash" +elif [ -f "$COMPLETION_DIR/volta.bash" ]; then + rm "$COMPLETION_DIR/volta.bash" fi ### wp-cli (only bash available) -if command -v wp > /dev/null && [ -f /usr/local/src/wp-cli/wp-completion.bash ]; then - cp /usr/local/src/wp-cli/wp-completion.bash "$COMPLETION_DIR/wp.bash" -elif command -v wp > /dev/null; then +if command -v wp > /dev/null; then curl -sSL https://raw.githubusercontent.com/wp-cli/wp-cli/v2.7.1/utils/wp-completion.bash > "$COMPLETION_DIR/wp.bash" +elif [ -f "$COMPLETION_DIR/wp.bash" ]; then + rm "$COMPLETION_DIR/wp.bash" fi ### zoxide if command -v zoxide >/dev/null; then zoxide init bash > "$COMPLETION_DIR/zoxide.bash" +elif [ -f "$COMPLETION_DIR/zoxide.bash" ]; then + rm "$COMPLETION_DIR/zoxide.bash" fi