Skip to content

Commit

Permalink
themes/powerline: Add possibility to add \n to the end of commands
Browse files Browse the repository at this point in the history
  • Loading branch information
diegom-ciandt authored and akinomyoga committed Apr 9, 2023
1 parent 0e9f0e7 commit 771b57e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions themes/powerline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ You can change the format using the following variable:

The time/date is printed by the `date` command, so refer to its man page to change the format.

### New Line

You can move the cursor to a new line after each command using the following variable:

POWERLINE_PROMPT_NEWLINE=true

The prompt will receive a "\n" at the end. This is usefull if you navigate a lot to folders with extensive names.

### Segment Order

The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are:
Expand Down
4 changes: 3 additions & 1 deletion themes/powerline/powerline.base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Define this here so it can be used by all of the Powerline themes
THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=false}
POWERLINE_PROMPT_NEWLINE=${POWERLINE_PROMPT_NEWLINE:=false}

function set_color {
if [[ "${1}" != "-" ]]; then
Expand Down Expand Up @@ -161,8 +162,9 @@ function __powerline_prompt_command {
done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${_omb_prompt_normal}"
[[ "${POWERLINE_PROMPT_NEWLINE=}" == true ]] && END_PROMPT=" \n" || END_PROMPT=""

PS1="${LEFT_PROMPT} "
PS1="${LEFT_PROMPT}${END_PROMPT}"

## cleanup ##
unset LAST_SEGMENT_COLOR \
Expand Down

0 comments on commit 771b57e

Please sign in to comment.