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 08:50AM
Show HN: Try my new Bash prompt https://ift.tt/1LVzxvF
Related Articles
Show HN: Prevent failed login attempts on your Linux server https://ift.tt/39aSJGPShow HN: Prevent failed login attempts on your Linux server https://if… Read More
Show HN: Bree is the best Node.js job scheduler (cron and human-friendly syntax) https://ift.tt/30xdE39Show HN: Bree is the best Node.js job scheduler (cron and human-friend… Read More
Show HN: Select&Speak – privacy-focused text-to-speech bookmarklet https://ift.tt/2DHbEgHShow HN: Select&Speak – privacy-focused text-to-speech bookmarklet… Read More
Show HN: Open-source multi-tier website backups (files & MySQL DBs) using Docker https://ift.tt/2OBOJpkShow HN: Open-source multi-tier website backups (files & MySQL DBs… Read More
Show HN: Backlogs – Collect users feedback and create product changelog https://ift.tt/2OvuwRUShow HN: Backlogs – Collect users feedback and create product changelo… Read More
Show HN: Dockerfiler: declarative management of images built from Dockerfiles https://ift.tt/2ZGHpiFShow HN: Dockerfiler: declarative management of images built from Dock… Read More
Show HN: Notepad – A fast and simple text editor on Windows for over 30 years https://ift.tt/3jlbLinShow HN: Notepad – A fast and simple text editor on Windows for over 3… Read More
Show HN: Buttery, a DSL/runtime for defining HTTP APIs https://ift.tt/2OzAJN3Show HN: Buttery, a DSL/runtime for defining HTTP APIs https://ift.tt/… Read More
0 Comments: