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

Allow the icon and the states in the dir segment to be easy configurable by users. #98

Merged
merged 2 commits into from
Jul 1, 2019

Conversation

raul-benito
Copy link

I want to add new icons depending on the path. I think the easiest way is to allow the users to modify an associative array.

Please tell me what you think about this approach.

Raul Benito Garcia added 2 commits July 1, 2019 13:46
The next PR will add the possibility of adding new icons to different
paths.
@romkatv romkatv merged commit 6f14212 into romkatv:master Jul 1, 2019
@romkatv
Copy link
Owner

romkatv commented Jul 1, 2019

Thanks for the contribution. Looks useful.

I've merged it after a few changes. You can now define POWERLEVEL9K_DIR_CLASSES to specify custom styling and icons for different directories.

POWERLEVEL9K_DIR_CLASSES must be an array with 3 * N elements. Each triplet consists of:

  1. A pattern against which the current directory is matched. Matching is done with extended_glob option enabled.
  2. Directory class for the purpose of styling.
  3. Icon.

Triplets are tried in order. The first triplet whose pattern matches $PWD wins. If there are no matches, there will be no icon and the styling is done according to POWERLEVEL9K_DIR_BACKGROUND,
POWERLEVEL9K_DIR_FOREGROUND, etc.

Example:

POWERLEVEL9K_DIR_CLASSES=(
    '~/work(/*)#'  WORK     '(╯°□°)╯︵ ┻━┻'
    '~(/*)#'       HOME     ''
    '*'            DEFAULT  '')

POWERLEVEL9K_DIR_WORK_BACKGROUND=red
POWERLEVEL9K_DIR_HOME_BACKGROUND=blue
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND=yellow

With the settings, the current directory in the prompt may look like this:

(╯°□°)╯︵ ┻━┻ ~/work/projects/important/urgent

⌂ ~/best/powerlevel10k

@romkatv
Copy link
Owner

romkatv commented Dec 9, 2019

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

Successfully merging this pull request may close these issues.

2 participants