Skip to content

Instantly share code, notes, and snippets.

@adduc
Last active January 25, 2025 21:01
Show Gist options
  • Save adduc/2aa137f08a1a1e6f1eb27b812f463640 to your computer and use it in GitHub Desktop.
Save adduc/2aa137f08a1a1e6f1eb27b812f463640 to your computer and use it in GitHub Desktop.
bash prompt

Bash Prompt

My current directory structure can result in lengthy directory paths, which can make for difficult bash prompts with Fedora's default prompt. To deal with this, I constructed a bash prompt that allows for lengthy directory paths without impacting where the cursor for the command begins.

PS1

# set prompt: <horizontal line>\n<green>user@hostname</green>:<cyan>current directory</cyan>\n<yellow>time</yellow> $
export PS1="\[\033[1;30m\]$(printf '─%.0s' {1..80})\n\[\033[0;32m\]\u@\h\[\033[0m\]:\[\033[0;36m\]\w\[\033[0m\]\n\[\033[0;33m\]\t\[\033[0m\] $ "

Example

────────────────────────────────────────────────────────────────────────────────
user@hostname:~/path/to/dir
14:23:35 $ ^C
────────────────────────────────────────────────────────────────────────────────
user@hostname:~/path/to/dir
14:23:35 $ time

real    0m0.001s
user    0m0.000s
sys     0m0.001s
────────────────────────────────────────────────────────────────────────────────
user@hostname:~/path/to/dir
14:23:35 $ 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment