3 ms·
I think a huge amount of these prompts are just fiddling with things because people think they are clever, not because they are actually useful. My prompt for
by JimDabell 3y ago
I think a huge amount of these prompts are just fiddling with things because people think they are clever, not because they are actually useful.
My prompt for years has been:
: ▶
I add the hostname if it’s an SSH session and change ▶ to # if I’m root because those are both important contexts that should be omnipresent, but aside from that, I haven’t felt like I’m missing anything at all. The CWD is in the window / tab title bar, but I never need to look at it because the CWD is always so closely tied to what I am doing in the shell that it’s always top of mind.
- adhesive_wombat 3y agoGit information is extremely useful to me. I notice colleagues who don't have that tend to struggle using git on the command line and use git status nearly every other command (much as I tend to do when I'm remoting into a shell with a plain prompt). Python venvs are useful too if you have a shell for running the program and other shells that just happen to be within that directory.
- tracker1 3y agoLargely of the same mind. I've found starship very useful and have been using it everywhere I can fit a few years now.
- the_gipsy 3y agoIt's probably a bell curve and you're only seeing the left side.
- mort96 3y agoHuh? What here is a bell curve? What would be on the "right side" of the bell curve that invalidates the idea that git info in PS1 is useful?
- the_gipsy 3y agohttps://s3-alpha.figma.com/hub/file/1263794301/resized/800x480/e9421029-9d4f-498f-a2c3-f3c2e2e55bae-cover.png https://s3-alpha.figma.com/hub/file/1263794301/resized/800x4... Left: confused and no prompt Middle: proficient and with prompt Right: proficient and no prompt
- happymellon 3y agoYes, having the git project displayed is useful. To a lesser extent, I've done a few Java version migrations so it can be useful for the Java version to be printed so it's obvious if I've got the wrong JDK enabled. Python fell under this, but I don't think I'll have to worry about having one project be Python 2 while the others are 3 anymore.
- JimDabell 3y ago> Git information is extremely useful to me. I could see the case for that if it were accurate. But every implementation I’ve seen doesn’t give you accurate Git information. It gives you the status of the repo as it was when you last ran a command. If you are working on the repo in a separate editor window, then the Git information in your prompt is usually incorrect. Incorrect information is worse than no information. Besides which, your editor normally provides this information as you are working on it. Why does outdated Git information belong in a prompt when there are more convenient places to get the correct information?
- adhesive_wombat 3y agoI can honestly say that has never once been a problem I have had, and I've had git information in the prompt for over 10 years. Also how is "enter" less convenient than literally any other command that you'd still have to type and run to get up-to-date information in a command line?
- JimDabell 3y ago> I can honestly say that has never once been a problem I have had, and I've had git information in the prompt for over 10 years. What do you mean exactly? Are you saying it doesn’t get out of date? i.e. you never change the state of the repository outside of your terminal session? I don’t think that’s reflective of how most people work. Are you saying that it gets out of date but that doesn’t matter? If that’s the case, then it’s a strong hint that the information isn’t as useful as you assume. What’s the point in constantly, repeatedly showing incorrect information? Are you saying that you work around the problem by hitting enter whenever you want an update? Then aren’t you doing the same thing as your colleagues who you mention struggle with Git? Hitting enter in your case is essentially a shortcut for running `git status` over and over, except you are doing it with literally every command you run instead of only when you need to. > Also how is "enter" less convenient than literally any other command that you'd still have to type and run to get up-to-date information in a command line? The issue is the space and attention used by repeatedly showing outdated Git information. Space and attention are at a premium in a terminal window; you can’t just dump all the information available to you in there for free.
- Arch-TK 3y ago>struggle using git on the command line and use git status nearly every other command I think you are conflating two separate things. I don't care for starship or prompts which show git status information. But, when interacting with git, I do often type git status. That being said, I don't struggle with git. Really, when I don't need status information, I don't want the horizontal space taken up with an unnecessarily noisy prompt.
- angra_mainyu 3y agoI have a tiny prompt I wrote that adds two important bits: git branch w/ status (if in a git repo) and venv (if any). So it looks like: me@pop-os 09:19:20 files: 49 ~> /path/to/cwd $ by default and in a git repo: me@pop-os 09:20:14 files: 18 ~> ~/dev/work/projects/someproject [ git ~ feature/some-feature || Add: 0 Mod: 1 Del: 0 Unt: 0 ] $ in a venv: me@pop-os 09:20:14 files: 18 (venv: my-venv) ~> ~/dev/work/projects/someproject [ git ~ feature/some-feature || Add: 0 Mod: 1 Del: 0 Unt: 0 ] $ Note, these all use different font colors to be distinguishing.
- neilv 3y agoI do the same thing with SSH sessions (no hostname if local). Also: * username if it's not "me" * indicator if in `screen` or `tmux` session * `cwd` * in reverse-video or bold, on terminals that support that, to stand out All these things have been useful many times. Most often, which is shells on local laptop, the prompt is only a reverse-video cwd. The extras appear for less-usual situations. I should add Git info.
- mort96 3y ago[flagged]
- pdimitar 3y agoThe GIT status prompt is immensely useful. Not as useful, but still occasionally useful, are the prompts for language / tool versions. And how much time did the last command take. I make a regular use of that when I don't need sub-second timings. If that makes me "thinking I am clever" then by all means, spend your life believing that. It increases my productivity though.
- JimDabell 3y ago> If that makes me "thinking I am clever" then by all means, spend your life believing that. It increases my productivity though. If it increases your productivity, then it’s the opposite of what I’m talking about.
- tetris11 3y agoI like this approach. I tried using starship.rs but I have to say it does far more than I want it to and makes me feel like I'm not in control of my shell (e.g. it pulls a schema via an URL without any knowledge from me that it does so). As a result, I've written my own small and concise PS1 which covers all my use cases: ## Add this to ~/.bashrc force_color_prompt=yes ## show: user+hostname (if ssh), conda, venv, guix, and git function prompt_command { ## styles and symbols local RESET='\[\033[0m\]' ; local BLD_GRN='\[\033[1;32m\]'; local BLD_YLW='\[\033[1;33m\]'; local BLD_PPL='\[\033[1;35m\]'; local BLD_CYN='\[\033[1;36m\]'; local BLD_WHT='\[\033[1;37m\]' local ITL_YLW='\[\033[3;33m\]'; local SEP='⋮' PROMPT_DIRTRIM=2 export PS1="" if [ -n "$SSH_CONNECTION" ]; then PS1=${PS1}${BLD_CYN}'\u'${BLD_YLW}'@'${BLD_GRN}'\h'${RESET} fi if [ -n "$CONDA_DEFAULT_ENV" ]; then PS1=${PS1}${SEP}${ITL_YLW}${CONDA_DEFAULT_ENV}${RESET} fi if [ -n "$VIRTUAL_ENV" ]; then PS1=${PS1}${SEP}${BLD_WHT}${VIRTUAL_ENV##*/}${RESET} fi if [ -n "$GUIX_ENVIRONMENT" ]; then PS1=${PS1}${SEP}${BLD_GRN}'GUIX'${RESET} fi if [ -e .git ]; then PS1=${PS1}${SEP}${BLD_PPL}$(git branch --show-current)${RESET} fi PS1=${PS1}${SEP}${BLD_GRN}'\w' # short directory PS1=${PS1}${BLD_YLW}'▶ '${RESET} } export PROMPT_COMMAND=prompt_command Fast and easy to grok.