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

[Agnoster theme] Add the prompt view customization ability #7355

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

apodkutin
Copy link

@apodkutin apodkutin commented Oct 27, 2018

By default prompt has these segments: prompt_status, prompt_context, prompt_virtualenv, prompt_dir, prompt_git, prompt_end in that particular order.

If you want to add, change the order or remove some segments of the prompt, you can use array environment variable named AGNOSTER_PROMPT.

Examples:

  • Show all segments of the prompt with indices:
echo "${(F)AGNOSTER_PROMPT[@]}" | cat -n
  • Add the new segment of the prompt to the beginning:
AGNOSTER_PROMPT=("prompt_git" "${AGNOSTER_PROMPT[@]}")
  • Add the new segment of the prompt to the end:
AGNOSTER_PROMPT+="prompt_end"
  • Insert the new segment of the prompt = PROMPT_SEGMENT_NAME on the particular position = PROMPT_SEGMENT_POSITION:
PROMPT_SEGMENT_POSITION=5 PROMPT_SEGMENT_NAME="prompt_end";\
AGNOSTER_PROMPT=("${AGNOSTER_PROMPT[@]:0:$PROMPT_SEGMENT_POSITION-1}" "$PROMPT_SEGMENT_NAME" "${AGNOSTER_PROMPT[@]:$PROMPT_SEGMENT_POSITION-1}");\
unset PROMPT_SEGMENT_POSITION PROMPT_SEGMENT_NAME
  • Swap segments 4th and 5th:
SWAP_SEGMENTS=(4 5);\
TMP_VAR="$AGNOSTER_PROMPT[$SWAP_SEGMENTS[1]]"; AGNOSTER_PROMPT[$SWAP_SEGMENTS[1]]="$AGNOSTER_PROMPT[$SWAP_SEGMENTS[2]]"; AGNOSTER_PROMPT[$SWAP_SEGMENTS[2]]="$TMP_VAR"
unset SWAP_SEGMENTS TMP_VAR
  • Remove the 5th segment:
AGNOSTER_PROMPT[5]=

A small demo of the dummy custom prompt segment, which has been created with help of the built-in prompt_segment() function from Agnoster theme:

# prompt_segment() - Takes two arguments, background and foreground.
# Both can be omitted, rendering default background/foreground.

customize_agnoster() {
  prompt_segment 'red' '' ' ⚙ ⚡⚡⚡ ⚙  '
}

Customization demo

@mcornella mcornella added Area: theme Issue or PR related to a theme Status: conflicts Pull Request that has conflicts with the master branch labels Mar 24, 2019
@ohmyzsh ohmyzsh bot removed the Status: conflicts Pull Request that has conflicts with the master branch label Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: theme Issue or PR related to a theme
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

None yet

2 participants