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 convert POWERLEVEL9K config? #6

Open
fniessen opened this issue Jun 27, 2019 · 5 comments
Open

How to convert POWERLEVEL9K config? #6

fniessen opened this issue Jun 27, 2019 · 5 comments

Comments

@fniessen
Copy link

Dear,

I had this config before:

# Single-line prompt.
POWERLEVEL9K_PROMPT_ON_NEWLINE=false
POWERLEVEL9K_RPROMPT_ON_NEWLINE=false

POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=''
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX=''

# Customise the Powerlevel9k prompts.
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time time background_jobs)

POWERLEVEL9K_STATUS_VERBOSE=false
POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE=true
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=10
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M}"

How to get the same prompt with Zinc?

What annoys me currently is the user@hostname part at the beginning of the PROMPT. I almost do not use ssh, and so this is a big part of space taken for nothing -- I'd like that to be auto-visible, though, in ssh sessions, but that may be not possible.

And I'd like the time format to be just HH:MM.

And finally I'd like the duration for "long commands" to be shown if the command is taking more than 10 seconds.

On the other hand, I enjoy a lot your exit code (which really give the number instead of a red cross), and I appreciate a lot the SIGINT marker as well! I wanna keep those as-is!

@robobenklein
Copy link
Owner

It's fairly simple to implement, here's what I came up with:


zinc_default_user="robo"
zinc_default_host="robo-unseptium"

# either user and host separate with CONNECT_PREV
# or zincs_userhost
zinc_left=(
  # zincs_user
  # zincs_host
  zincs_userhost
  zincs_cwd
  zincs_vcs
)

zinc_right=(
  zincs_retval
  zincs_execution_time
  my_custom_time
  zincs_jobs
)

zinc_opts=(
  zincs_user "white;black;CONDITIONAL;normal"
  zincs_host "white;black;CONNECT_PREV+CONDITIONAL;normal"
  zincs_userhost "white;black;CONDITIONAL;normal"
)

# autohide the user when it's default
function zincs_user_display_hidden () {
  [[ "$USER" == "$zinc_default_user" ]] && true || false
}
function zincs_host_display_hidden () {
  [[ "$HOST" == "$zinc_default_host" ]] && true || false
}

# or show both when either changes:
function zincs_userhost_display_hidden () {
  [[ "$HOST" == "$zinc_default_host" ]] && [[ "$USER" == "$zinc_default_user" ]] && true
}

# set the time format option:
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html
function my_custom_time () {
  REPLY="%T"
}

# set the zincs_execution_time min time:
zincs_execution_time[threshold]=10

Of course you'd need to change zinc_default_host/user but that I think is the mostly equivalent config.

@robobenklein
Copy link
Owner

Alright, I put that config into the presets: prompt_zinc_setup fniessen-p9k-port

Is that about what you expect?

@robobenklein
Copy link
Owner

Screenshot from 2019-06-27 17-30-59

@fniessen
Copy link
Author

Now, I just have this code:

ZSH_THEME=""
source "$ZSH_CUSTOM"/themes/zinc/zinc.zsh

zinc_default_user="f.niessen"
zinc_default_host="XIPHIAS"

prompt_zinc_setup fniessen-p9k-port

but got the error:

/cygdrive/d/Users/fni/.dotfiles/plugins/oh-my-zsh/custom/themes/zinc/presets/fniessen-p9k-port.zincp.zsh:49: zincs_execution_time: assignment to invalid subscript range

@robobenklein
Copy link
Owner

Just updated the preset, does that help? (Forgot about an older zsh behaviour)

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

No branches or pull requests

2 participants