From 1f38446b846b0b0c51ee810acafdee4922dca284 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Thu, 23 Sep 2021 14:16:27 +0300 Subject: [PATCH] ref --- .bash_aliases | 8 ++++---- .bashrc | 2 +- README.md | 24 +++++++++++++++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index ddec757..7746a57 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -50,19 +50,19 @@ alias tar-it='tar -czf "../${PWD##*/}.tar.gz" .' untar() { if ! [ -f $1 ]; then - echo "\033[0;31merror: file '$1' not found\e[m" >&2 + echo "error: file '$1' not found" >&2 return 1 # exit code fi - + local dir_name dir_name="$(basename $1 | cut -d. -f1)" if [ -d $dir_name ]; then - echo "\033[0;31merror: directory '$dir_name' exists\e[m" >&2 + echo "error: directory '$dir_name' exists" >&2 return 1 # exit code fi if [ -f $dir_name ]; then - echo "\033[0;31merror: file '$dir_name' exists\e[m" >&2 + echo "error: file '$dir_name' exists" >&2 return 1 # exit code fi diff --git a/.bashrc b/.bashrc index f1db8c4..1839b62 100644 --- a/.bashrc +++ b/.bashrc @@ -19,7 +19,7 @@ parse_git_branch() { echo '' return fi - + local branch branch="$(git branch --show-current 2> /dev/null)" if [[ -n "$branch" ]]; then diff --git a/README.md b/README.md index f11ce47..88c9c0b 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,8 @@ sudo systemctl status .service sudo systemctl enable .service ``` -**"/etc/systemd/system/.service"** + +#### file "/etc/systemd/system/.service" ```text [Unit] Description= @@ -110,6 +111,27 @@ RestartSec=5 WantedBy=multi-user.target ``` + + +### Autocomplete + +#### file "/etc/bash_completion.d/ssh" +```bash +_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 + +``` + +