Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Expanding on custom directory icons #1387

Open
gallagherman opened this issue Dec 9, 2019 · 2 comments
Open

Expanding on custom directory icons #1387

gallagherman opened this issue Dec 9, 2019 · 2 comments

Comments

@gallagherman
Copy link

gallagherman commented Dec 9, 2019

First I just want to say that I am brand new to git and contributing to open source projects. This might be a simple issue.

I want to modify the prompt_dir() function in powerklevel9k.zsh-theme to include more conditions to replace the icon depending of the state_path.

This issue is related to #606.

This can be easily done if you just add dir states and separate conditions. For instance, here I've added a "DROPBOX""state that uses "DROPBOX_ICON" for paths that contain '~/dropbox'*, almost exactly the same as the current/etc conditions.

  # save state of path for highlighting and bold options
  local path_opt=$current_path

  typeset -AH dir_states
  dir_states=(
    "DEFAULT"         "FOLDER_ICON"
    "HOME"            "HOME_ICON"
    "HOME_SUBFOLDER"  "HOME_SUB_ICON"
    "NOT_WRITABLE"    "LOCK_ICON"
    "ETC"             "ETC_ICON"
    "DROPBOX"         "DROPBOX_ICON"
  )
  local state_path="$(print -P '%~')"
  local current_state="DEFAULT"
  if [[ $state_path == '/etc'* ]]; then
    current_state='ETC'
  elif [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then
    current_state="NOT_WRITABLE"
  elif [[ $state_path == '~/dropbox'* ]]; then
    current_state="DROPBOX"
  elif [[ $state_path == '~' ]]; then
    current_state="HOME"
  elif [[ $state_path == '~'* ]]; then
    current_state="HOME_SUBFOLDER"
  fi

My question is; how could we do this within .zshrc instead of modifying powerline9k.zsh-theme?
I've seen other users utilize the custom_user prompt status in .zshrc to easily add icons and the like, but to my knowledge there is not a custom_dir status to do the same thing, and even so would it allow conditional formatting to icons?

@gallagherman
Copy link
Author

@romkatv
Looks nice in powerlevel10k! So this is not addressed in powerlevel9k?

@romkatv
Copy link

romkatv commented Dec 9, 2019

Looks nice in powerlevel10k!

Thanks!

So this is not addressed in powerlevel9k?

No.

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

No branches or pull requests

2 participants