Normally I don't post much about how a site should use HTTPS on HN, but for this specific instance I think it's important.
why?
Bash PS1 Generator
81–90 of 146 posts
Re: Bash PS1 Generator
#82I've been using this for years (output of 'echo $PS1' ): [\e[1;33m\u\e[1;32m@\e[1;31m\H \e[1;36m\t\e[0m] [\e[1;35m\w\e[0m](\e[1;32m\#\e[0m )\n$ which presents as: [User@HOST 10:21:07][~](2) $ (Username, hostname, 24 hour local time, CWD, history count, newline, prompt) More detail from my .bashrc: # Define some colors first: red='\e[0;31m' RED='\e[1;31m' blue='\e[0;34m' BLUE='\e[1;34m' cyan='\e[0;36m' CYAN='\e[1;36m'…
What do you use the history count for?
!! repeats the last command
!N repeats the command with that index in the history
Re: Bash PS1 Generator
#83Was expecting this: ________________ | |," `.| | SgH | / SONY \ | |O _\ /> /_ | ___ _ |_(_)'.____.'(_)_| (")__(") [___|[=]__[=]|___] // \\
Re: Bash PS1 Generator
#84Somewhat related to PS1 is PS4 in bash. Make your trace output more useful/verbose in your scripts: set -x export PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: ' This will print the filename, function name, line number, and line content during execution.
Re: Bash PS1 Generator
#85All this stuff is easy to remember. I want colors so bad. You could even have colors be containers you put other elements inside to make it easier to visualize
Re: Bash PS1 Generator
#86Re: Bash PS1 Generator
#87Apparently the extension PS1 is a reference to PowerShell 1.0.0, thankfully Microsoft did not increase the number.
Source
Re: Bash PS1 Generator
#88current git branch is missing (helps me to avoid working on the wrong branch). (tried to do it with colors, but things got too messy). I never managed to work with colors in bash propmts; they look different on each environment. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } PS1="[\u@\h \W\$(parse_git_branch)]\$ "
You might want to use `git rev-parse --abbrev-ref HEAD` or `git name-rev --name-only HEAD` instead of `git branch`. Plumbing commands (such as rev-parse or name-ref) are generally more interface-stable to use in a script than porcelain commands (such as git branch) which are designed for interactive use where output may change depending on user environment and configuration.
Re: Bash PS1 Generator
#89What is the best way to have the long directory line above the prompt? Using PS2 or PS3?