From 28b82022eb0a2ee4121d517700906984f8eb0734 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 2 Feb 2022 10:39:51 +1300 Subject: bashrc: Don't print anything unless interactive This fixes broken scp. --- bashrc | 55 ++++++++++++------------------------------------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/bashrc b/bashrc index 05e3333..ac8c12f 100644 --- a/bashrc +++ b/bashrc @@ -1,50 +1,19 @@ #!/usr/bin/bash -c_off='\e[0m' -c_bold='\e[1m' -c_black='\e[30m' -c_red='\e[31m' -c_green='\e[32m' -c_yellow='\e[33m' -c_blue='\e[34m' -c_purple='\e[35m' -c_cyan='\e[36m' -c_white='\e[37m' - export HISTSIZE=10000 export HISTTIMEFORMAT="%y-%m-%d %T " -source /usr/share/git/completion/git-prompt.sh - -if [ "$TERM" == "st-256color" ]; then - # Quick fix for ctrl+arrow key in st - echo $(tput smkx) > /dev/tty -fi - -############### -PS1="${c_bold}${c_yellow}\ -┌[${c_green}\u${c_yellow}@${c_blue}\h${c_yellow}][${c_purple}\W${c_yellow}"'$(__git_ps1 " (%s)")'"] ${c_black}<\d \t>${c_yellow}\n\ -└╼ \[${c_off}\]" -############### - -source ~/.aliases -source ~/.environment - -echo Running $(uname) $(uname -r) on $(uname -n) \($(uname -m)\) - -if [ -f ~/todo ]; then - echo To do: - cat ~/todo -fi - -if [ -f ~/.cache/weather/forecast ]; then - echo "" - echo Weather: - cat ~/.cache/weather/forecast | while read -r l ; do echo " "$l ; done -fi +case $- in + *i*) + # interactive, continue fancy stuff. Printing anything when a + # non-interactive session is active breaks scp and other utils + source ~/.aliases + source ~/.environment -[ -d ~/Maildir/new/ ] && [ "$(ls ~/Maildir/new/)" ] && echo 'New mail' + echo Running $(uname) $(uname -r) on $(uname -n) \($(uname -m)\) + ;; + *) + # non-interactive, don't do anything fancy + ;; +esac -[ -z "$(ls -A ~/.cache/currency 2>/dev/null)" ] || for c in ~/.cache/currency/* ; do - echo "$(cat $c) (at $(date -d $(stat -c %Y $c) +"%a %d %H:%M"))" -done -- cgit v1.1