Last active
November 20, 2020 19:59
-
-
Save ben-bradley/f1ca93fa44829ccd127a to your computer and use it in GitHub Desktop.
shell prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shell prompt stuff | |
function dashes() { | |
COLS=$(tput cols) | |
D=${PWD/$HOME/\~} | |
U=$(whoami) | |
H=$(hostname -s) | |
FLEN=16 # constant for spaces & timestamp | |
CLEN=$(( ${#D}+${#U}+${#H}+$FLEN )) | |
DLEN=$(( $COLS-$CLEN )) | |
DASH="━" | |
#DASH="─" | |
DASHES="" | |
for (( a=1; a <= DLEN; a++ )); do | |
DASHES=$DASHES$DASH | |
done | |
echo -n ${DASHES} | |
} | |
function makePrompt() { | |
# ANSI color codes | |
RS="\[\033[0m\]" # reset | |
HC="\[\033[1m\]" # hicolor | |
UL="\[\033[4m\]" # underline | |
INV="\[\033[7m\]" # inverse background and foreground | |
FBLK="\[\033[30m\]" # foreground black | |
FRED="\[\033[31m\]" # foreground red | |
FGRN="\[\033[32m\]" # foreground green | |
FYEL="\[\033[33m\]" # foreground yellow | |
FBLE="\[\033[34m\]" # foreground blue | |
FMAG="\[\033[35m\]" # foreground magenta | |
FCYN="\[\033[36m\]" # foreground cyan | |
FWHT="\[\033[37m\]" # foreground white | |
BBLK="\[\033[40m\]" # background black | |
BRED="\[\033[41m\]" # background red | |
BGRN="\[\033[42m\]" # background green | |
BYEL="\[\033[43m\]" # background yellow | |
BBLE="\[\033[44m\]" # background blue | |
BMAG="\[\033[45m\]" # background magenta | |
BCYN="\[\033[46m\]" # background cyan | |
BWHT="\[\033[47m\]" # background white | |
RARR="▶" | |
LARR="◀" | |
# echo -n "$HC$BBLK$FCYN \u@\h $RS$BCYN$FBLK \w \$(dashes) $RS$HC$BBLK$FCYN \t $RS\n$HC$BBLK$FCYN$INV \$ $RS" | |
echo -n "$HC$BBLK$FCYN \u@\h $RS$FBLK \w \$(dashes) $RS$HC$BBLK$FCYN \t $RS\n$HC$BBLK$FCYN \$ $RS" | |
} | |
export PS1="$(makePrompt)" |
UPDATE: fixed some problems & added colors
ben@ubuntu-lappy ~/Documents ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 09:18:20
$
also for reference - https://unicode-table.com/en/#2501
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output of this in your terminal will look like this:
The string of dashes will adapt to fit the terminal width and the current directory so it should be pretty flexible.