8 ms·
The stock PS1 bugged me a bit, so I mangled it down to this That's not too far from this one which I use and have seen quite a few others use too --- really ha
by userbinator 4y ago
The stock PS1 bugged me a bit, so I mangled it down to this
That's not too far from this one which I use and have seen quite a few others use too --- really hate a lot of the newer defaults that hide the full path for some reason, and managed to convince a coworker who accidentally edited the file of the same name in the same directory with a different path to use it too:
'\u@\h:\w$ '
Also I should mention that in this era of constant telemetry^Wspyware and tracking, everything you say can and will be used to identify or correlate you, and that does include using non-default configuration. Of course, how much this matters depends on the context in which you say it.
- deafpolygon 4y agoMine is even simpler... '> %d ' (yes, I use zsh) Root has '# %d ' Am I odd? I generally find I don't need /that/ much information on the shell.
- yjftsjthsd-h 4y agoI like to get exit codes, but otherwise yeah that's fine.
- ofalkaed 4y agoI use ... for user and []_ for root, I would rather not fill up terminal space with information I generally know. I really hate when the prompt causes things to wrap and I do not mind putting pwd or the like to use on those occasions I do not know.
- lloeki 4y agoha. mine is: ~> although it gets progressively richer with heightened context, e.g: username if not my account hostname if ssh'ing basename(pwd) (not full path) if not ~ HEAD value (ref or sha) if in git or hg literal rebase & al for stateful git operation in progress any of ! ≠ ± (untracked, unstaged, and staged changes) any of literal nix venv when entering specific contexts at some point I had it as simple as > but some situations had me wish I knew context right away so I progressively added these each time I had a "fuck, I made a mistake and I would not have if I had that bit of context" I thought I'd go all the way to ; plan9 rc-style which made sense because "select whole line then paste and run" just works. plus it looks like a wink. I do have colours in a few select areas, but very limited, so that when there are colours they are very meaningful. notably the prompt segments are colour coded by meaning since they're dynamic. my vim theme looks like e-ink, merely getting fancy with a shade of gray for comments (which at some point could be reverted so thar comments get the "focus" and code is toned down, very literal programming) oh and please: no right prompt, ever (or $COLUMNS-wide left prompt) as it gets wild when resizing; no freaking emoji in my output (e.g I still have that HOMEBRE_NO_EMOJI env var set to an expletive of sorts even though I don't use homebrew anymore)
- JimDabell 4y agoI do the same – starting out simple then adding context – but with: : ▶ The colon (normally) acts as a no-op, so if you copy and paste an entire line including the prompt and run it, it does nothing.
- bostik 4y agoHah, my ~minimalist variant must look outright flashy compared to yours. Thus: PS1='%U%m%u:%B%30<..<%~%b%% ' I like to know which host I'm on directly from the shell prompt, as well as the trail end of CWD. You could get close to the same with just '%30d' but then I'd lose the visual cues. And it must have been that way for at least 15 years.
- Kwpolska 4y agoThe full directory can make your prompt very long and ugly in some cases. I'm using zsh’s RPROMPT instead, the main prompt to the left displays the basename, and the right-side prompt displays the full path (if it fits on the line).
- jrockway 4y agoI like having the full path. I just put my prompt on two lines so that the path doesn't interfere with the beautiful shell command I am composing: \[\033[01;32m\]\n[\w] \j (\u@\h)\n$ \[\033[00m\] (As you might guess, I do not share the author's distaste for colors. Colors are great. In this one, I picked green.)
- Tyr42 4y agoAh, a fellow two line prompt enjoyer. I usually have the full path, but I special case a few "well known" paths, like home home shortens to ~
- jrockway 4y agoYup. It seems to be \w that does that. (This is bash, which probably matters.)
- akkartik 4y agoI have a similar prompt. Having commands alone on a line makes them easier to grab with OP's beloved triple click. Multi-line commands indent right, so I'm more likely to use them. And I added the color after having trouble picking out the boundary between commands with pages of output.
- TristanBall 4y agoI've moved to two line prompts everywhere as well, the second line being basically just " > " I've also added inter prompt spacing.. first that was just an extra \n before the prompt, but I decided I wanted space between the prompt and the start of program output, as well as between the end of output and the next prompt. I can't remember where I stole the idea from to give credit, and it feels a little wrong but works really well: For bash, in PROMPT_COMMAND, set a debug trap that writes a newline, and then removes itself "trap - DEBUG". If it's not obvious the debug trap fires right after you hit return, but before the command actually runs ( also making it a nice place to update xterm/tmux titles ). So that gets you your post prompt newline, but then because the traps removed it doesn't keep firing for every command in you for loop or whatever. But PROMPT_COMMAND adds the trap again for the next time. I also have some weird logic in prompt_command that only adds the preprompt newline if the cursor isn't in column 0, because I found otherwise I was getting unnecessary extra spacing. So yes, if I hit enter on a plain prompt I get two blank lines before the next one.. so? But it makes differentiating output so much easier. Combine with colour prompts with timestamps ( and in history too ) and I get at least rough timing on how long tasks take, which is often useful. It's actually on monochrome terminals (for whatever dumb reason that might be happening) that it helps the most, to the point where now when I see a non customised terminal my reaction is "urhg.. what's all this mess, take it away" <shooing wave of hands> That and pspg for database/csv viewing make my daily life measurably better.