From 03a388f509634b620b5f7888a08b225d314c3e57 Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 19 Aug 2024 19:19:58 +0200 Subject: [PATCH] addet universal install alias 'install_pkg' --- .bashrc | 38 +++++++++++++++++++++----------------- .completions/ssh | 12 ++++++++++++ 2 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 .completions/ssh diff --git a/.bashrc b/.bashrc index 3834036..6c3b5db 100644 --- a/.bashrc +++ b/.bashrc @@ -4,6 +4,25 @@ function echo_error() { echo -e "\033[0;1;31merror:\033[0;31m\t${*}\033[0m"; } function echo_binfo() { echo -e "\033[0;1;34mInfo:\033[0;34m\t${*}\033[0m"; } function echo_info() { echo -e "\033[0;35m${*}\033[0m"; } +if command_exists curl; then + alias install_pkg='bash -c "$(curl -sSL https://git.k4li.de/pika/scripts/raw/branch/main/bash/snippets/install_pkg.sh)" -- ' +else + echo_error "curl is not installed, universal install disabled!" +fi + +i_blesh() { + install_pkg gawk make && + git clone https://github.com/akinomyoga/ble.sh.git /tmp/blesh && + $(cd /tmp/blesh && make && make INSDIR="$HOME/.local/share/blesh" install) +} +# ─< ble.sh -- https://github.com/akinomyoga/ble.sh >───────────────────────────────────── +if [[ ! -f $HOME/.local/share/blesh/ble.sh ]]; then + i_blesh +else + [[ $- == *i* ]] && + source "$HOME/.local/share/blesh/ble.sh" --attach=none +fi + _sensible.bash_() { # Sensible Bash - An attempt at saner Bash defaults # Maintainer: mrzool @@ -140,22 +159,8 @@ _defaults_() { if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi -} - -p_blesh() { - i_blesh() { - install gawk make && - git clone https://github.com/akinomyoga/ble.sh.git /tmp/blesh && - cd /tmp/blesh && - make - make INSDIR="$HOME/.local/share/blesh" install - } - # ─< ble.sh -- https://github.com/akinomyoga/ble.sh >───────────────────────────────────── - if [[ ! -e $HOME/.local/share/blesh/ble.sh ]]; then - i_blesh - else - [[ $- == *i* ]] && - source "$HOME/.local/share/blesh/ble.sh" --attach=none + if [ -f ~/.completions/ssh ]; then + . ~/.completions/ssh fi } @@ -184,7 +189,6 @@ plugins() { # [[ -s "$HOME/.qfc/bin/qfc.sh" ]] && source "$HOME/.qfc/bin/qfc.sh" # p_basher p_has - p_blesh } _color_prompt_() { diff --git a/.completions/ssh b/.completions/ssh new file mode 100644 index 0000000..e99584a --- /dev/null +++ b/.completions/ssh @@ -0,0 +1,12 @@ +_ssh() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-) + + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return 0 +} +complete -F _ssh ssh