Skip to content

Prompt customization #356

Closed
Closed

Description

@ashrithr

Is there a way to customize the prompt by setting variables or configuration?

Activity

  1. sophiajt commented on Aug 24, 2019

    @sophiajt
    Contributor

    You can't customize the prompt, yet. That's something we could add in the future, though.

  2. Joshfindit commented on Aug 24, 2019

    @Joshfindit

    Biggest one for me: showing the git branch

  3. twe4ked commented on Aug 24, 2019

    @twe4ked
    Contributor

    It shows the git branch by default!

    /Users/odin/Dev/github/wycats/nushell(master)>
    
  4. added
    category:enhancement
    polish
    on Aug 26, 2019
  5. wycats commented on Aug 26, 2019

    @wycats
    Contributor

    I really want something like this (could be added to config). I'd like something better than the templating on offer in existing shells, which I can't, for the life of me, ever read.

  6. added
    status:needs-design
    on Aug 26, 2019
  7. djc commented on Aug 26, 2019

    @djc
    Contributor

    Have been thinking about this for the past few days. Some design thoughts:

    For reference, what I've been using for bash: export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \W \$\[\033[00m\] '

    And zsh:

    autoload -Uz vcs_info
    zstyle ':vcs_info:*' enable git
    zstyle ':vcs_info:git*' formats "%F{green}%b%f "
    zstyle ':vcs_info:git*' actionformats "%F{green}%b (%a)%f "
    precmd() {
        vcs_info
        PS1="%B%F{blue}%m%f ${vcs_info_msg_0_}%F{blue}%1~ \$%f%b "
    }

    I think maybe we could use format-like strings for variables, like this:

    {host} {user} {cwd} {vcs} $

    And maybe some kinds of tags for colors? You can do foreground and background colors, so maybe prefix with f and b (or fg and bg)? Could use [] or <> or ().

    <f:bright-green>{user}@{host}</f:bright-green> {cwd} $

  8. sophiajt commented on Aug 26, 2019

    @sophiajt
    Contributor

    @djc I really like this:

    {host} {user} {cwd} {vcs} $
    

    We've been talking about using similar syntax for a string parsing function, so this would be a nice parallel people could learn and use.

  9. wycats commented on Aug 26, 2019

    @wycats
    Contributor

    Something like this seems very cool.

  10. jedahan commented on Aug 27, 2019

    @jedahan

    I really like just setting an environment variable to an array of functions. As long as the functions print to stdout, it allows people to define arbitrary customizations without needing to rely on builtins.

    It would be nice to have left and right prompt. See https://github.com/geometry-zsh/geometry as an example of what I mean.

  11. Southclaws commented on Sep 13, 2019

    @Southclaws
    Contributor

    I'd love to join this shell with the Starship prompt, both written in Rust, it's a match made in heaven!

    https://github.com/starship/starship

    I'm not certain on how starship is implemented under the hood though, so I'm not totally sure how easy it would be to integrate. But, it might be as simple as just importing the crate given it's Rust!

  12. Southclaws commented on Oct 8, 2019

    @Southclaws
    Contributor

    7 Emojis seems like enough interest, I have poked around the code and it seems easy enough but will require a PR to the Starship repo to make it more library-friendly as currently it just writes directly to stdout - would be neater if there was a neatly exposed function to return the prompt as a string.

    I could make it invoke the starship command externally but it just seems like such a good opportunity to grab some performance given both of these things are written in Rust!

  13. kbd commented on Nov 8, 2019

    @kbd

    I really like just setting an environment variable to an array of functions.

    I always love feeling seen by fellow geeks. That’s how I do my prompt and I wasn’t previously familiar with geometry.

  14. sophiajt commented on Nov 30, 2019

    @sophiajt
    Contributor

    As of 0.6.0, you can use starship. I'll close this issue, but if we feel like we want non-starship customization, we can explore that in a different issue.

  15. sophiajt commented on Jun 28, 2020

    @sophiajt
    Contributor

    For those finding this later, we did end up implementing configuring the internal prompt: #2064

    It should be part of the 0.16.0 release.

  16. pvarga-dni commented on Apr 25, 2022

    @pvarga-dni

    For those ending up here nowadays:

    let-env PROMPT_COMMAND_RIGHT = '' # ...to hide the right prompt, for example. Or:
    let-env PROMPT_COMMAND = { your | awesome | prompt } # ...where "your awesome prompt" can be
                                                         # any series of commands
  17. gadzhi-m commented on Jun 10, 2022

    @gadzhi-m

    Hello. How can I change the path in the prompt line from full path (/home/user) to tilde (~)?

  18. added a commit that references this issue on Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:enhancementpolishstatus:needs-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions