From fbe1ac82f102aee58f38063afcd56838b795dbbc Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 20 Apr 2022 21:57:31 +0300 Subject: [PATCH] add completion for bkp, add func destroy --- sub/bash/completion | 10 ++++++++++ sub/bash/functions | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/sub/bash/completion b/sub/bash/completion index 2bb4569..3560488 100644 --- a/sub/bash/completion +++ b/sub/bash/completion @@ -7,6 +7,15 @@ _ssh() { return 0 } +_bkp() { + local cur opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + opts=$(ls ~/.backup/1) + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return 0 +} + _workon() { local cur prev envs COMPREPLY=() @@ -20,4 +29,5 @@ _workon() { complete -F _workon workon complete -F _ssh ssh complete -F _ssh sftp +complete -F _bkp bkp diff --git a/sub/bash/functions b/sub/bash/functions index f102754..eaa54a5 100644 --- a/sub/bash/functions +++ b/sub/bash/functions @@ -1,4 +1,14 @@ + +destroy() { + test -n "$1" || return 1 + test -e "$1" || return 1 + + echo "Sure want to destroy file '$1' with size $(du -hs "$1" | awk '{printf $1}') [y/N] " + read -r response + [[ $response == [yY] ]] && shred -zun 25 "$1" +} + lsl () { local DIR