From 9208fc1cdce2526f2f093586f13a014e7d5b2ab1 Mon Sep 17 00:00:00 2001 From: Ntentos Stavros <133706+stdedos@users.noreply.github.com> Date: Mon, 28 May 2018 23:18:14 +0300 Subject: [PATCH] POC: Adding bash-completion to byobu. * Linking repositories containing the files for future traceability (License: GPLv2) * Symlinking the required files * Adding bash-completion to byobu executables: * Hard-coding `byobu-tmux` and `byobu-screen` to respected complete-functions * Small shim to redirect on the correct bash-completion function in case of using the plain `byobu` (as expected on the normal usecase) Tested under Ubuntu 16.04.3. _Note that unfortunately, I didn't have screen installed to test or verify the actual usage of `screen` file. I am not familiar with `screen` commands, but I was seeing bash functionality "completed". However, autocomplete changed realtime to the contents of `source`d file._ Signed-off-by: Ntentos Stavros <133706+stdedos@users.noreply.github.com> --- .gitmodules | 6 ++++++ bash-completion | 1 + etc/bash_completion.d/byobu | 17 +++++++++++++++++ etc/bash_completion.d/screen | 1 + etc/bash_completion.d/tmux | 1 + tmux-bash-completion | 1 + 6 files changed, 27 insertions(+) create mode 100644 .gitmodules create mode 160000 bash-completion create mode 100644 etc/bash_completion.d/byobu create mode 120000 etc/bash_completion.d/screen create mode 120000 etc/bash_completion.d/tmux create mode 160000 tmux-bash-completion diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..3da474a5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "bash-completion"] + path = bash-completion + url = https://github.com/GArik/bash-completion.git +[submodule "tmux-bash-completion"] + path = tmux-bash-completion + url = https://github.com/imomaliev/tmux-bash-completion.git diff --git a/bash-completion b/bash-completion new file mode 160000 index 00000000..afe39fd1 --- /dev/null +++ b/bash-completion @@ -0,0 +1 @@ +Subproject commit afe39fd1e171d0ea3d4fb8ec0d8c8c14fa120ed8 diff --git a/etc/bash_completion.d/byobu b/etc/bash_completion.d/byobu new file mode 100644 index 00000000..7e59569b --- /dev/null +++ b/etc/bash_completion.d/byobu @@ -0,0 +1,17 @@ +#!/bin/bash + +_byobu() { + source <(sed 's/^/local /' "${HOME}/.byobu/backend") + + if [ "${BYOBU_BACKEND}" == tmux ] ; then + _tmux "$@" + elif [ "${BYOBU_BACKEND}" == screen ] ; then + _screen "$@" + else + return 1 + fi +} + +complete -F _byobu byobu +complete -F _tmux byobu-tmux +complete -F _screen byobu-screen diff --git a/etc/bash_completion.d/screen b/etc/bash_completion.d/screen new file mode 120000 index 00000000..766b3a7e --- /dev/null +++ b/etc/bash_completion.d/screen @@ -0,0 +1 @@ +bash-completion/completions/screen \ No newline at end of file diff --git a/etc/bash_completion.d/tmux b/etc/bash_completion.d/tmux new file mode 120000 index 00000000..8d8dc336 --- /dev/null +++ b/etc/bash_completion.d/tmux @@ -0,0 +1 @@ +tmux-bash-completion/completions/tmux \ No newline at end of file diff --git a/tmux-bash-completion b/tmux-bash-completion new file mode 160000 index 00000000..847eda60 --- /dev/null +++ b/tmux-bash-completion @@ -0,0 +1 @@ +Subproject commit 847eda60c4664bfca833a086a3e2167957c26be0