Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purpose of the white cross at the beginning of the prompt #44

Open
johnnymetz opened this issue Jun 19, 2021 · 3 comments
Open

Purpose of the white cross at the beginning of the prompt #44

johnnymetz opened this issue Jun 19, 2021 · 3 comments

Comments

@johnnymetz
Copy link

What is the purpose of the white cross with the black background at the beginning of the prompt?

Screen Shot 2021-06-19 at 2 02 16 AM

It doesn't seem to change at all. Can I change it to an emoji or something else?

@Asjas
Copy link

Asjas commented Jun 19, 2021

Wes probably just wanted to use it as a symbol, it's an emoji that you can change yourself. It's on the end of this line 🙂

https://github.com/wesbos/Cobalt2-iterm/blob/master/cobalt2.zsh-theme#L52

@outofcontrol
Copy link

Okay, it's been awhile, but stumbled across this will updating my dotfiles. The cross appears when you are ssh to a different users on the same machine, or when you ssh into a different machine that also has the cobalt2 setup.

@7stud
Copy link

7stud commented Dec 20, 2023

I'm using Terminal on macOS, and I used https://github.com/jabranr/cobalt2-like to setup the cobalt2 theme in Terminal. The instructions there have us do your installation first, then some additional steps. When I open a Terminal window, I get the cross at the start of the prompt. $DEFAULT_USER is not set nor is $SSH_CLIENT. I have seen some examples where there is a home icon or folder icon at the start of the prompt depending on what directory you are in. Any suggestions for getting that setup?

Somewhere, someone suggested doing this:


You could write a function like this, replacing 'home' and 'not home' with your icons

zsh_prompt_home_indicator() {
    if [[ "$PWD" = "$HOME" ]];then
        echo "home"
    else
        echo "not home"
    fi
}

then add $(zsh_prompt_home_indicator) to your PROMPT where you want the icons to appear.


I tried the following in ~/.oh_my_zsh/themes/cobalt2.zsh-theme:

...
...
prompt_context() {
  local user=`whoami`

  #if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
  if [[ -n "$SSH_CLIENT" ]]; then   <====CHANGED
    prompt_segment black default "%(!.%{%F{yellow}%}.)✝"
  else   <=============ADDED
    prompt_segment blue default "%(!.%{%F{yellow}%}.)"   <==========ADDED
  fi
}

...
...

##### I added this: ######
zsh_prompt_home_indicator() {
    if [[ "$PWD" = "$HOME" ]];then
        echo 🏡
    else
        echo 📂
    fi
}
###################

PROMPT='%{%f%b%k%}$(zsh_prompt_home_indicator)$(build_prompt) '

That "works" somewhat: the icons are displayed correctly at the start of the prompt, but they are not on a blue background. As a test, I used the cross character in the else branch of prompt_context(), and I deleted $(zsh_prompt_home_indicator) from the PROMPT= line, and the cross does appear on the blue background. I surmise that the icons I'm using take up the whole area allotted for the character or don't have a transparent background. Where do the icons, like on this guys cobalt2 themed prompt, come from: https://youtu.be/8JJ101D3knE?si=kSk1_kaJG2bUON_K&t=820

Screen Shot 2024-01-10 at 9 25 17 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants