spaceship-prompt / spaceship-prompt

:rocket::star: Minimalistic, powerful and extremely customizable Zsh prompt
https://spaceship-prompt.sh
MIT License
19.53k stars 965 forks source link

Git User #1362

Open lobosan opened 1 year ago

lobosan commented 1 year ago

The problem

I work with several github accounts and to me it is useful to display my github user in my prompt

Describe the solution you'd like

Show the github user before the current directory like this:

image

where lobosan is my github username

Describe alternatives you've considered

No response

Documentation and adoption

No response

denysdovhan commented 1 year ago

Any suggestions how to get current active GitHub user? Are you using gh tool?

lobosan commented 1 year ago

When using oh-my-zsh I use the avit theme, and display my git name by adding $(git config user.name) to the _user_host function You can have a look at the whole theme here https://github.com/lobosan/zsh-theme/blob/main/avit.zsh-theme#LL16C1-L27C2 So, it would be great if you could add it to the spaceship configuration. In my case I'm installing it through fig, so it would be nice to see it under the git section

image
denysdovhan commented 1 year ago

You are confusing git with github. It's not the same. Git is a VCS. GitHub is a hosting (website) for Git repos.

Yes, it's possible to display the result of git config user.name, though it's probably not the info you need to know when typing every other command. You probably need that once in a while, don't you?

lobosan commented 1 year ago

Yes, I meant github user. This info is important to me when I'm in a folder that is a github repo, not on every command.

denysdovhan commented 1 year ago

Again, git config user.name doesn't show your GitHub user. It shows you Git user.

lobosan commented 1 year ago

you right sorry for the confusion, but is it possible to show my git user when working on a project with git?

denysdovhan commented 1 year ago

Sure, you can do it yourselft. Here's a guide how to create a custom section: https://spaceship-prompt.sh/advanced/creating-section/#Typical-section-breakdown

You can create your custom git_user section. Istead of foobar --version you can run git config user.name.

lobosan commented 1 year ago

thanks @denysdovhan