From 5032772c2a295d885cdbac419a32b2ed2e528f2b Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Thu, 3 Feb 2022 01:02:41 -0300 Subject: Add completion support --- session.bash | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'session.bash') diff --git a/session.bash b/session.bash index caa35de..d6c02b3 100644 --- a/session.bash +++ b/session.bash @@ -30,6 +30,18 @@ session() { false fi } +# setup completion for session(), using only builtins +complete -C 'source <(printf "%s" '\'' + set -- ~/.bash_history."$2"* + flag=0 + [[ -e "$1" ]] && for f in "${@#~/.bash_history.}" ; do + if [[ "$f" =~ ^[a-z][a-z0-9]*$ ]] ; then + ((flag)) && printf "\n" + printf "%s" "$f" + flag=1 + fi + done +'\'')' session # sets the current cwd as the default cwd for the session setsessioncwd() { -- cgit 1.4.1