aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash')
-rw-r--r--bash/bash_completion.d/_ssh_config_hosts.bash29
-rw-r--r--bash/bash_completion.d/mosh.bash5
-rw-r--r--bash/bashrc4
-rw-r--r--bash/bashrc.d/prompt.bash34
4 files changed, 50 insertions, 22 deletions
diff --git a/bash/bash_completion.d/_ssh_config_hosts.bash b/bash/bash_completion.d/_ssh_config_hosts.bash
index 0959f52b..16265e8a 100644
--- a/bash/bash_completion.d/_ssh_config_hosts.bash
+++ b/bash/bash_completion.d/_ssh_config_hosts.bash
@@ -3,23 +3,28 @@ _ssh_config_hosts() {
# Iterate through SSH client config paths
local config
- for config in "$HOME"/.ssh/config /etc/ssh/ssh_config ; do
+ for config in /etc/ssh/ssh_config.d/*.conf /etc/ssh/ssh_config \
+ "$HOME"/.ssh/config.d/*.conf "$HOME"/.ssh/config ; do
[[ -e $config ]] || continue
- # Read 'Host' options and their first value from file
- local option value ci
- while read -r option value _ ; do
+ # Read 'Host' options and their patterns from file
+ local option value patterns pattern ci
+ while read -r option value ; do
[[ $option == Host ]] || continue
+ read -a patterns -r \
+ < <(printf '%s\n' "$value")
# Check host value
- case $value in
- # No empties
- '') ;;
- # No wildcards
- *'*'*) ;;
- # Found a match; print it
- "$2"*) COMPREPLY[ci++]=$value ;;
- esac
+ for pattern in "${patterns[@]}" ; do
+ case $pattern in
+ # No empties
+ '') ;;
+ # No wildcards
+ *'*'*) ;;
+ # Found a match; print it
+ "$2"*) COMPREPLY[ci++]=$pattern ;;
+ esac
+ done
done < "$config"
done
diff --git a/bash/bash_completion.d/mosh.bash b/bash/bash_completion.d/mosh.bash
new file mode 100644
index 00000000..17d72ca1
--- /dev/null
+++ b/bash/bash_completion.d/mosh.bash
@@ -0,0 +1,5 @@
+# Completion for mosh(1) with ssh_config(5) hostnames
+if ! declare -F _ssh_config_hosts >/dev/null ; then
+ source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash
+fi
+complete -F _ssh_config_hosts -o bashdefault -o default mosh
diff --git a/bash/bashrc b/bash/bashrc
index a60a047e..5d3a7bbc 100644
--- a/bash/bashrc
+++ b/bash/bashrc
@@ -28,8 +28,8 @@ fi
# Clear away command_not_found_handle if a system bashrc file set it up
unset -f command_not_found_handle
-# Keep around 32K lines of history in file
-HISTFILESIZE=32768
+# Keep around 128K lines of history in file
+HISTFILESIZE=131072
# Ignore duplicate commands
HISTCONTROL=ignoredups
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index f9678f20..e0a03438 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -7,29 +7,32 @@ prompt() {
# Turn complex, colored PS1 and debugging PS4 prompts on
on)
# Set up pre-prompt command
- PROMPT_COMMAND='history -a'
+ PROMPT_COMMAND='PROMPT_RETURN=$?;history -a'
# If Bash 4.0 is available, trim very long paths in prompt
if ((BASH_VERSINFO[0] >= 4)) ; then
PROMPT_DIRTRIM=4
fi
- # Basic prompt shape depends on whether we're in SSH or not
+ # Prompt has hostname via SSH outside of screen/tmux
PS1=
- if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then
+ if [[ -n $SSH_CLIENT && -z $STY && -z $TMUX ]] ; then
PS1=$PS1'\h:'
fi
PS1=$PS1'\w'
- # Add sub-commands; VCS, job, and return status checks
- PS1=$PS1'$(ret=$?;prompt vcs;prompt job;prompt ret)'
-
# Add a helpful prefix if this shell appears to be exotic
case ${SHELL##*/} in
(bash) ;;
(*) PS1=bash:$PS1 ;;
esac
+ # Add sub-commands:
+ ## Preload libraries as prefix
+ PS1='$(prompt preload)'$PS1
+ ## VCS, job, and return status checks as suffixes
+ PS1=$PS1'$(prompt vcs;prompt job;prompt ret)'
+
# Add prefix and suffix
PS1='${PROMPT_PREFIX}'$PS1'${PROMPT_SUFFIX}'
@@ -92,6 +95,21 @@ prompt() {
fi
;;
+ # Analyze LD_PRELOAD to see if we should report anything loaded
+ preload)
+ printf '%s:' "$LD_PRELOAD" |
+ while read -d : -r ; do
+ case $REPLY in
+ (*/libip2unix.so)
+ printf '[IP2Unix]'
+ ;;
+ (*/libtorsocks.so)
+ printf '[Tor]'
+ ;;
+ esac
+ done
+ ;;
+
# Git prompt function
git)
@@ -249,8 +267,8 @@ prompt() {
# Show return status of previous command in angle brackets, if not zero
ret)
# shellcheck disable=SC2154
- ((ret)) || return
- printf '<%u>' "${ret//\\/\\\\}"
+ ((PROMPT_RETURN)) || return
+ printf '<%u>' "${PROMPT_RETURN//\\/\\\\}"
;;
# Show the count of background jobs in curly brackets, if not zero