Show HN: Try my new Bash prompt https://ift.tt/07tx2kw

Show HN: Try my new Bash prompt PS1='\$ ' # short and sweet prompt old_cmdno=${old_cmdno-0} old_lines=${old_lines-0} old_cols=${old_cols-0} prepare_terminal() { stty rows $((LINES - 1)) printf "\n\033[1A" old_lines=$LINES old_cols=$COLUMNS } update_status_line() { local exit=$? local getcmdno='\#' local cmdno=${getcmdno@P} local esc=$(printf "\033") local pwd=$PWD local dots= [ $LINES -eq $old_lines -a $COLUMNS -eq $old_cols ] || prepare_terminal local status_esc="$esc[7m$esc[m" while true; do [ "${pwd#/*/}" == "$pwd" ] && break local status="$esc[7m$(date +%m-%d/%H:%M)$esc[m $HOSTNAME $dots$pwd" local status_len=$((${#status} - ${#status_esc})) [ $status_len -le $COLUMNS ] && break pwd=${pwd#/} pwd=/${pwd#*/} dots='...' done status_len=$((${#status} - ${#status_esc})) [ $status_len -gt $COLUMNS ] && status= printf "${esc}7$esc[%s;1H$esc[K%s$esc[1;%sr${esc}8" $((LINES + 1)) "$status" $LINES if [ $exit -ne 0 -a $cmdno -ne $old_cmdno ] ; then printf "!%s!\n" $exit fi old_cmdno=$cmdno } PROMPT_COMMAND='update_status_line' August 4, 2023 at 06:20AM

Post a Comment

0 Comments