5 ms·
The 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, an
by Kwpolska 4y ago
The 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 3y 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 3y 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.
- znpy 4y agoI actually have the full path in my PS1, and it actually spans two lines with the second line being only “$ “. The reality if my life is that I often work with long paths, and having the full path around saves me some pwd fairly often.
- hddqsb 3y agoBash has PROMPT_DIRTRIM to only print the last n components (this effect can also be achieved using zsh: https://unix.stackexchange.com/questions/273529/shorten-path-in-zsh-prompt https://unix.stackexchange.com/questions/273529/shorten-path...).