From 40532e1bc6fd1fb69abfba555286a441d64ce117 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Thu, 18 Aug 2022 16:36:05 +0100 Subject: [PATCH] Improve zsh behaviour --- roles/home-cli/files/bashrc | 66 ++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/roles/home-cli/files/bashrc b/roles/home-cli/files/bashrc index 9d4e1d7..6985312 100644 --- a/roles/home-cli/files/bashrc +++ b/roles/home-cli/files/bashrc @@ -15,23 +15,28 @@ then alias shopt=false fi -if [ -f /etc/bashrc ] +if [ -n "$BASH_VERSION" ] then - . /etc/bashrc -fi -if [ -f /usr/share/bash-completion/bash_completion ] -then - . /usr/share/bash-completion/bash_completion -elif [ -f /etc/bash_completion ] -then - . /etc/bash_completion -fi + if [ -f /etc/bashrc ] + then + . /etc/bashrc + fi + + if [ -f /usr/share/bash-completion/bash_completion ] + then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ] + then + . /etc/bash_completion + fi + + if [ -f /usr/share/bash-completion/completions/quilt ] + then + . /usr/share/bash-completion/completions/quilt + complete -F _quilt_completion -o filenames dquilt + fi -if [ -f /usr/share/bash-completion/completions/quilt ] -then - . /usr/share/bash-completion/completions/quilt - complete -F _quilt_completion -o filenames dquilt fi _acp_add_path () { @@ -88,7 +93,7 @@ export PAPERSIZE=a4 export POWERSHELL_TELEMETRY_OPTOUT=1 export PYTHONWARNINGS=ignore::UserWarning -if [ "x$(uname -s)" = "xDarwin" ] +if [ x$(uname -s) = xDarwin ] then export BASH_SILENCE_DEPRECATION_WARNING=1 fi @@ -115,25 +120,32 @@ then export QT_FONT_DPI=72 fi -shopt -s histappend -bind '"\e[1;5C": forward-word' -bind '"\e[1;5D": backward-word' -bind '"\e[A": history-search-backward' -bind '"\e[B": history-search-forward' -bind 'set bell-style none' -bind 'set completion-ignore-case on' -bind 'set enable-bracketed-paste off' - -if [ -n "$ZSH_VERSION" ] +if [ -n "$BASH_VERSION" ] +then + shopt -s histappend + bind '"\e[1;5C": forward-word' + bind '"\e[1;5D": backward-word' + bind '"\e[A": history-search-backward' + bind '"\e[B": history-search-forward' + bind 'set bell-style none' + bind 'set completion-ignore-case on' + bind 'set enable-bracketed-paste off' +elif [ -n "$ZSH_VERSION" ] then bindkey "^[[A" history-beginning-search-backward bindkey "^[[B" history-beginning-search-forward fi -export PS1="\[\033[01m\]\u@\h\\$\[\033[00m\] " -if [ -n "$ZSH_VERSION" ] +# Set the prompt for various shells. The prompt should look like "user@host$ " +# or similar, except for the fallback of "$ " for anything it can't detect. +if [ -n "$BASH_VERSION" ] +then + export PS1="\[\033[01m\]\u@\h\\$\[\033[00m\] " +elif [ -n "$ZSH_VERSION" ] then export PS1="%B%n@%m%#%b " +else + export PS1="$ " fi if test $(id -u) -ne 0 && test -x /usr/bin/dnf