[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
PS1 - Show me your promt
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 13
Thread images: 2
Show me your prompt, /g/. Post the source, shell, and any other details.

Bash 4.3.

export PROMPT_COMMAND=__prompt_command
function __prompt_command() {
local EXIT="$?"

local DEFAULT='\[\e[0m\]'

local RED='\[\e[0;31m\]'
local GREEN='\[\e[0;32m\]'
local DARK_GRAY='\[\e[0;90m\]'
local PURPLE='\[\e[0;35m\]'
local YELLOW='\[\e[0;33m\]'

PS1="\n${GREEN}\t${DEFAULT} "

if [ "$EXIT" != "0" ]; then
PS1+="${RED}$EXIT${DEFAULT} "
else
PS1+="$EXIT${DEFAULT} "
fi

JOBSCOUNT=$(jobs -p | wc -l)
if [ $JOBSCOUNT != "0" ]; then
PS1+="${YELLOW}$JOBSCOUNT${DEFAULT} "
fi


PS1+="${PURPLE}\w${DEFAULT}\n${DARK_GRAY}\u${DEFAULT}\\$ "
}
>>
>>55500705
Also, colors are Base 16 Monokai: https://chriskempson.github.io/base16/#monokai
>>
>>55500810
do you also wear a skirt?
>>
zsh.
~ λ echo $PS1
%{$fg[cyan]%}${PWD/#$HOME/~}%{$fg[magenta]%} λ %{$reset_color%}


>>55500705
>time in every single line
>>
>>55500897
I just added time recently, along with the blank line.

I first added it at work, where it is nice to be able to look at my sessions from yesterday and see when I started jobs, etc. I kinda like it, but I'm not completely sold yet.
>>
>>55500920
>>55500897
It's also useful as a "poor man's 'time'" on every command. I can go back and see how long something took to run, even if I didn't think to measure it the first time.
>>
am i a tard?
export PS1='[\u@\h \W]\$ '

maybe i ought to put the time in it and have colors but I don't want a super convoluted ps1
>>
>not having it do \b every line
why even have a speaker
>>
>>55500946
Nah, I used bare "$ " for a long time. Only add what you'll appreciate.
>>
>>55500975
i mean, colors look super nice, and having the time would be useful for when you're not in X
doing it rn
>>
can i have \A show the time in ISO 8601 (no separators)? muh tism demands it
>>
>>55501024
you know you can use any variable you want in PS1?
>>
>>55501024
>>55501094
You can also use PROMPT_COMMAND to build PS1 procedurally like I did in OP.
Thread replies: 13
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.