From 83a1c4a965b0c3f6d03ddf012c99ffdebe73bf7c Mon Sep 17 00:00:00 2001 From: OCram85 Date: Tue, 8 Nov 2022 15:44:27 +0100 Subject: [PATCH] add bash-completion and motd handling (#2) #### :book: Summary - adds bash completion for `install-revruntime` helper - adds motd handling. #### :bookmark_tabs: Test Plan > :bulb: Select your test plan for the code changes. - [x] Tested via Drone.io pipeline - [ ] Custom test - [ ] No test plan ##### Details / Justification #### :books: Additional Notes Co-authored-by: OCram85 Reviewed-on: https://gitea.ocram85.com/CodeServer/Container/pulls/2 --- Dockerfile | 6 +++++- install-devruntime | 11 +++++++++++ install-devruntime-completion | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 install-devruntime-completion diff --git a/Dockerfile b/Dockerfile index ee60171..f4a7e6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,10 @@ RUN \ echo 'source /usr/share/bash-completion/completions/git' >> /etc/bash.bashrc ADD install-devruntime /usr/bin/ +ADD install-devruntime-completion /etc/bash_completion.d/ RUN \ chmod +x /usr/bin/install-devruntime && \ - echo "echo \"Use 'install-devruntime' to install missing runtimes like dotnet or NodeJs.\"" >> /etc/bash.bashrc + chmod +x /etc/bash_completion.d/install-devruntime-completion && \ + echo 'source /etc/bash_completion.d/install-devruntime-completion' >> /etc/bash.bashrc && \ + touch "$HOME/enable_motd" && \ + echo "if [[ -e \"$HOME/enable_motd\" ]]; then echo -e \"Use \\e[32m'install-devruntime'\\e[0m to install missing runtimes like dotnet or NodeJs.\"; fi" >> /etc/bash.bashrc diff --git a/install-devruntime b/install-devruntime index 58b2a9d..680d04b 100755 --- a/install-devruntime +++ b/install-devruntime @@ -14,11 +14,19 @@ function showHelp() { nodejs Installs latest NodeJs LTS version. powershell Installs latest PowerShell LTS version. -h Prints this help messagee. + disablemotd Disables hint in new bash terminal Example 1: install-devruntime dotnet Example 2: install devruntime golang nodejs HELP } +function disableMotd() { + if [[ -e "$HOME/enable_motd" ]]; then + say "Disabling 'install-devruntime' motd..." "disableMotd" + rm -f "$HOME/enable_motd" + fi +} + function say() { if [[ -n "$2" ]]; then echo -e "\e[32mInstall-DevRuntime\e[0m \e[34m[$2]\e[0m: $1" @@ -122,6 +130,9 @@ function main() { instNodeJs elif [[ "$i" == "powershell" ]]; then instPwsh + elif [[ "$i" == "disablemotd" ]]; then + disableMotd + exit 0 else sayE "Unknown parameter value given!($i)." showHelp diff --git a/install-devruntime-completion b/install-devruntime-completion new file mode 100644 index 0000000..5c6c195 --- /dev/null +++ b/install-devruntime-completion @@ -0,0 +1,3 @@ +#!/bin/bash + +complete -W "disablemotd dotnet golang nodejs powershell -h" install-devruntime