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

How to use in P9K Theme? #12

Open
badummtss opened this issue Jun 9, 2019 · 14 comments
Open

How to use in P9K Theme? #12

badummtss opened this issue Jun 9, 2019 · 14 comments

Comments

@badummtss
Copy link

I playing with zsh, because of changing my terminal from bash to zsh.
I found this in https://medium.com/@oldwestaction/beautifying-your-terminal-with-zsh-prezto-powerlevel9k-9e8de2023046.

But i have no idea how to use it.

I like the flames and want to use them in my theme.

At the moment it looks like this:
Bildschirmfoto 2019-06-09 um 12 21 18

i want to change alle the left sided indicators with it, but i can't found a solution for it (trying out some fonts, without success.

I hope someone can help me out...

@extremepayne
Copy link

POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\UE0C0'

@Hub-K
Copy link

Hub-K commented Dec 11, 2019

Hi,

Am an noob to zsh and powerline themes. I stumbled over https://github.com/ryanoasis/powerline-extra-symbols and wanted to know how can i setup the Fire/Flame theme.

This is my current terminal view:
image

I am on oh my zsh, powerline10k and nerd font/hack.

Your help is much appreciated!

Thanks,
Keus

@extremepayne
Copy link

I used prezto, but I believe the line I posted above

POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\UE0C0'

goes in your .zshrc. Along with any other customizations.
\UE0C0 denotes the segment you want to use as its Unicode, according to the README of this repo.
I chose to escape the Unicode address instead of pasting in the symbol because things like Github (if you check your dotfiles into a repo for VCS for example) won't render the symbols correctly.
I see you're using macOS. I hope you're using iTerm2. If you are, do note that I ran into some issues with certain symbols. (Specifically the fire one, if I remember correctly.) I seem to remember the author of this repo told someone to select the option to "treat ambiguous width characters as double-width" but I can't remember if that helped.
Oh here it is.
And also, .zshrc goes in your ~ directory.
Sorry for my inconclusiveness, I don't have the machine I used this on anymore.

@extremepayne
Copy link

@badummtss @Hub-K Did that fix it for you guys? You might also want to set POWERLEVEL9K_RIGHT_SEGMENT_SEPERATOR and the POWERLEVEL9K_<side>_SUBSEGMENT_SEPERATORs for both right and left to give it a more complete look.

@Hub-K
Copy link

Hub-K commented Dec 23, 2019

Nop, i tried using it with no avail.
Here is what i tried:

  1. I am using PowerLevel10K and not PowerLevel9K
  2. I am using NerdFonts Hacker font regular
  3. I tried :
    POWERLEVEL9K_RIGHT_SEGMENT_SEPERATOR
    POWERLEVEL10K_RIGHT_SEGMENT_SEPERATOR
    in ./zshrc with no effect.

is there any preconditions or steps i need to do/install to make this thing work. From what i understand, patched fonts like Hacker Font Regular by NerdFonts should include those separators.

@extremepayne
Copy link

extremepayne commented Dec 25, 2019

Alrighty. First off, p10k uses POWERLEVEL9K in its config to maintain forward compatibility with p9k. This way, no changes to config are needed if you are switching to powerlevel10k from p9k. Secondly, ~/.zshrc should be a dotfile (that is, it has a leading period). If these bits of advice fix your problem, you can skip the rest, but otherwise, get ready to make a really good bug report. (The instructions below are indeed the kind of verbosity I want when reading an issue.)
Also, ./zshrc isn't enough info--the "dot" directory is relative. Please use absolute directories like ~ (tilde dir; stands for /home/username) when asking for debugging help.

I will need a ton of info to tell what's going wrong. Please bear with me and paste all of this in, I don't know where the problem is, so I'll need to make sure everything is up-to-date and configured correctly.

  1. OS name. I assume it's macOS from your above screenshot, but just to make sure.
  2. OS version. This can be accessed by clicking the apple logo in the top bar and then clicking "about this mac". Hopefully, you're on 10.15.x; upgrade if you can.
  3. What terminal emulator (terminal) are you using? (Consider using iTerm2 if you aren't already. It's simply the best macOS option by a long shot.)
  4. The version of your terminal emulator. I think 3.3.7 is the most recent stable release of iTerm2. Again, upgrade if you need to.
  5. What does echo $SHELL print? zsh right?
  6. What zsh plugin manager, if any, are you using? Does this bundle p10k (as zprezto does)? Or did you install via the plugin manager? By cloning the git repo?
  7. Is your plugin manager/all plugins up to date? I don't know what command to run here since you might be using any of several dozen plugin managers, but a quick google search or --help flag should reveal the magic command(s).
  8. You've installed Hacker Font regular NF on your machine, correct? Via the download link on the nerdfonts homepage, or via the patcher script?
  9. Screenshot your terminal emulator's font settings page. It should have Hacker Font regular NF selected. If you're using different fonts for ascii and non-ascii, is the NF one the non-ascii one?
  10. What does your ~/.zshrc look like? Paste in any relevant bits (i.e. anything that starts with POWERLEVEL9K). Your previous comment mentioned only right prompt adjustments, and your left prompt is the main one. You should definitely be adjusting that one.
  11. Finally, and this might be the most helpful bit, screenshot the result when ALL of the following are entered into your ~/.zshrc:
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\UE0C0'
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\UE0C2'
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\UE0C1'
POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='\UE0C3'

Rember to write the file to disk (save it) before looking for a change. In addition, you'll need to open a new terminal window, as ~/.zshrc is only run upon startup. You might even have to restart your terminal emulator (⌘ Q, then open your terminal emulator again) for the changes to take effect. Or (I know, I know) restart your computer. Ya never know. Restarting is kinda magical.

Overall tips that led me to ask for this:

  1. Update everything.
  2. If someone is trying to remotely debug your config, screenshots of the result are immensely helpful.

Also, disclaimer, I'm not the maintainer (of any of the involved projects), I just happen to have some experience with the subject at hand.

@Hub-K
Copy link

Hub-K commented Dec 27, 2019

  1. macOS Catalina
  2. Vserion 10.15.2 (19C57)
  3. Native and iTerm2
  4. iTerm2 (Build 3.3.7)
  5. /bin/zsh
  6. oh my zsh installed using Curl sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  7. Yes, oh my zsh is updated to date. ran upgrade_oh_my_zsh
  8. Github repo https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Hack/Regular/complete/Hack%20Regular%20Nerd%20Font%20Complete.ttf and just click-to-install

image
image
10)

ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_MODE='nerdfont-complete'
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\UE0C0'
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\UE0C2'
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\UE0C1'
POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='\UE0C3'

//Terminal OSX
image

//iTerm2
image

@extremepayne
Copy link

Hm. iTerm is certainly doing a better job of rendering your prompt, but neither of them are picking up on your config.

Did you try restarting your computer? Also, you might try moving the POWERLEVEL9K stuff to different places in your .zshrc -- I've heard that placing them above or below certain things can stop it from working.

Oooh! What if -- do you have a .p10k.zsh? If so, you'll want to find those settings (they're set somewhere in there, use your editor's find) and replace them with your own. Then you won't need them in your .zshrc. That could definitely be it -- sorry about not mentioning that from the first, but I hadn't used p10k in months when I first replied to you.

@Hub-K
Copy link

Hub-K commented Dec 27, 2019

so i guess i took a step in the right direction, had to put it after the following:

source ~/powerlevel10k/powerlevel10k.zsh-theme
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\UE0C0'
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\UE0C2'
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\UE0C1'
POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='\UE0C3'

BUT, it looks so ugly:
image

  1. is there a way to make it have flames after each folder:
    image
    Since it looks more like:
    image

  2. how can i get the colour scheme (red, orange and yellow)

Thanks in advance

@extremepayne
Copy link

extremepayne commented Dec 30, 2019

Yes, that is definitely a step in the right direction.
You're using p10k, did you ever use the built-in configuration wizard? Did it generate a file? Looking maybe a bit like this?

If so, what you're going to want to do is open that file and make all of your edits there. The comments explain things pretty well and I've been able to customize mine just with the comments and the find feature of my editor. Plus, you won't have any POWERLEVEL9K stuff in your .zshrc.

If not, keep making the adjustments in your .zshrc. Also, it looks like you've selected the "classic" option if you wouldn't mind going in and reselecting the "rainbow" option, that's closer to your desired prompt. And "flat" instead of "faded" edges. Run p10k configure to do this.

But as for making the prompt look exactly like the maintainers, I'll tag him for you.
Hey @ryanoasis how did you make the fire prompt?

And in case he doesn't have a definitive answer (this was like several months ago, if not more, that he made the picture), here are some ideas:
Run this

for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done

to generate your colormap. For me, the firey-est colors are 001, 005, 003, 009, 124, 160, 196, 226. That might be different for you.
You'll want to change

POWERLEVEL9K_DIR_BACKGROUND
POWERLEVEL9K_OS_ICON_BACKGROUND

and perhaps

POWERLEVEL9K_TIME_BACKGROUND
POWERLEVEL9K_STATUS_OK_BACKGROUND

to those colors. Along with any others that might show up from time to time, such as:

POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND
POWERLEVEL9K_STATUS_OK_PIPE_BACKGROUND

And a whole ton of other possible segments. Like so many, it boggles the mind how this theme could possibly have been written.
So, you've changed all the colors to firey? Great! The next bit should be easier! Add

POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\UE0C0'
POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\UE0C2'

and you'll have more fire!
And now the hardest part: getting fire instead of slashes for your directories. I have no idea how to do this, but a rough sketch would be:
Find where p10k picks up your current directory from. This might be pwd, might be something else. You'll need to look at the source code for this, which you probably already have cloned, and it'll be in the file called internal/p10k.zsh. This 6,000 line beast has a directory segment being built somewhere in there.

Next, you'll need to fork p10k. You'll have to remember to keep to up to date with regular rebases or merges (or make a regularly run script [i.e. via cron] to automate it). Then you'll need to figure out how to avoid plugin manager conflicts. I use prezto so I don't know how oh-my-zsh works and can't offer any help as to how to do this. You might need to rename it so that the update command doesn't overwrite it with master of romkatv's version. powerlevel11k perhaps? Or p10kfire? If this sounds like too much work, it probably is. I don't maintain personalized forks of things ever and it sounds kinda difficult, tbh, especially in conjunction with a plugin manager.

So now you have a fork and know where the directory segment is coming from internally. Then you'll need to take that text that's getting shipped off to the directory segment and intercept it with some pipes. These should pipe it through some commands to find any forward slashes and replace them with the fire character. My *nix-command-line-fu is very google-reliant, so I'm not sure what commands you'd need to do this. I wouldn't know until I tried.

Sound like a lot of work? It certainly is. Unless someone publishes their config, trying to replicate it is gonna be hard. (P.S. my guess is that Ryan's prompt was actually just something he echoed or mocked up in a similar way, so this prompt never has existed as a real prompt. In that screenshot, you can see his actual prompt, , and his cursor, above and below the fire. Ryan, please correct me if I misrepresent you.)(looked again and this is in fact a prompt, but not sure if p10k or not.)

@Hub-K
Copy link

Hub-K commented Dec 30, 2019

You are awesome @extremepayne,

Here how it looks like now:
image

Here is my config:

POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\UE0C0'
POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\UE0C1'
POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\UE0C0'
#Left Segment
POWERLEVEL9K_DIR_BACKGROUND='166'
POWERLEVEL9K_OS_ICON_BACKGROUND='214'
#Right Segment
POWERLEVEL9K_TIME_BACKGROUND='095'
POWERLEVEL9K_STATUS_OK_BACKGROUND='179'
#Additional 
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='178'
POWERLEVEL9K_STATUS_OK_PIPE_BACKGROUND='000'
#End 
POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\UE0C0'

Remaining issues:

  1. How can i fix the Right Segment flame alignment, looks ugly due to check mark byP10K:

image
image

  1. Do you know how can i change the color of the Right Segment text, its black and i would like to have it white

Thanks a million

@extremepayne
Copy link

You are awesome @extremepayne,

Thanks!
Remaining issues:

How can i fix the Right Segment flame alignment, looks ugly due to check mark byP10K:

Try adding a space. Before the Unicode, I think. You also might want one afterward on the left side.

Do you know how can i change the color of the Right Segment text, its black and i would like to have it white

So figure out what the segment is called. In this case, it's both COMMAND_EXECUTION_TIME and TIME. Then change POWERLEVEL9K_<segment name>_FOREGROUND to a numerical value representing white--remember that colormap trick I showed you earlier?

Also, I see you've got a transparent background--iTerm2 has a specific setting to make powerline characters look better with transparency. "Keep background colors opaque" in profiles. See if you like it.

Lastly, and I should have mentioned this earlier, the docs that led me to be so knowledgeable about powerlevel9k/10k are here: https://github.com/Powerlevel9k/powerlevel9k/blob/master/README.md#prompt-customization
Some more are here:
https://github.com/Powerlevel9k/powerlevel9k/wiki/Stylizing-Your-Prompt
And I learned quite a bit from looking at other's configs:
https://github.com/Powerlevel9k/powerlevel9k/wiki/Show-Off-Your-Config
And most recently from the comments in this file:
https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-rainbow.zsh

@Hub-K
Copy link

Hub-K commented Jan 3, 2020

Try adding a space. Before the Unicode

POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' \UE0C2 ' //Worked !!!

Then change POWERLEVEL9K__FOREGROUND

POWERLEVEL9K_TIME_FOREGROUND="255"
Ref: https://github.com/Powerlevel9k/powerlevel9k/wiki/Show-Off-Your-Config

End result:
Screen Shot 2020-01-03 at 2 47 22 PM

@extremepayne you are a genius, thanks for helping and bearing with me through all the process, u da b3st.

@romkatv
Copy link

romkatv commented Feb 6, 2020

  1. is there a way to make it have flames after each folder:
    image

This should work:

# User-define prompt segment: my_fire_dir.
# It's a good idea to prefix your segments with `my_` to
# avoid clashes with future versions of powerlevel10k.
function prompt_my_fire_dir() {
  emulate -L zsh
  local split_path=(${(s:/:)${(%):-%~}//\%/%%})
  (( $#split_path )) || split_path+=/
  if (( $#split_path == 1)); then
    p10k segment -s SOLO -b 160 -f 255 -t $split_path
    return
  fi
  p10k segment -s FIRST -b 209 -f 255 -t $split_path[1]
  shift split_path
  while (( $#split_path > 1 )); do
    p10k segment -s EVEN -b 202 -f 255 -t $split_path[1]
    shift split_path
    (( $#split_path > 1 )) || break
    p10k segment -s ODD -b 209 -f 255 -t $split_path[1]
    shift split_path
  done
  p10k segment -s LAST -b 160 -f 255 -t $split_path[1]
}

typeset -g POWERLEVEL9K_MY_FIRE_DIR_LEFT_SEGMENT_SEPARATOR='\uE0C0'
typeset -g POWERLEVEL9K_MY_FIRE_DIR_{LAST,SOLO}_{LEFT_SEGMENT_SEPARATOR,LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL}='\uE0C0'

typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(my_fire_dir)

p10k-fire-dir

If you've never used p10k segment before, type p10k help segment for usage. Also see prompt_example in your ~/.p10k.zsh.

Some details about my_fire_prompt: romkatv/powerlevel10k#114 (comment).

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