Skip to content

Commit

Permalink
Merge pull request #33 from santicardona/make-new-line-fancy
Browse files Browse the repository at this point in the history
Added option for command on new line after prompt and made it fancy
  • Loading branch information
andresgongora authored Aug 8, 2023
2 parents c65bfc2 + fa491d6 commit 91ced85
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 19 deletions.
4 changes: 4 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ You may add your name, email, a link to your personal web-site/blog/profile
* **Dhia Hmila**
2022 - Use Python environment's alternative name if it exists


* **Santiago Cardona**
2023 - Command on new line after the prompt




Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ folders depending on how you installed **synth-shell**:
* Current-user only: `~/.config/synth-shell/`
* System wide: `/etc/synth-shell/`

#### Command in new line
In addition to having the command-line right after the prompt, it is possible to set-up **synth-shell** to instead display the command on the next line, which looks like this:

![next_line_command](doc/next_line_command.png)


This can be achieved by changing the option `enable_command_on_new_line=false` to `enable_command_on_new_line=true` on the `MAIN FORMAT` section of the `synth-shell-prompt.config` file.



Expand Down
5 changes: 3 additions & 2 deletions config/examples/synth-shell-prompt.blue.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ texteffect_input="bold"
##==============================================================================
## BEHAVIOR
##==============================================================================
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
enable_command_on_new_line=false # Add new line between prompt and command


##==============================================================================
Expand Down
6 changes: 4 additions & 2 deletions config/examples/synth-shell-prompt.gray.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ texteffect_input="bold"
##==============================================================================
## BEHAVIOR
##==============================================================================
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
enable_command_on_new_line=false # Add new line between prompt and command



##==============================================================================
Expand Down
6 changes: 4 additions & 2 deletions config/examples/synth-shell-prompt.green.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ texteffect_input="bold"
##==============================================================================
## BEHAVIOR
##==============================================================================
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
enable_command_on_new_line=false # Add new line between prompt and command




Expand Down
6 changes: 4 additions & 2 deletions config/examples/synth-shell-prompt.orange.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ texteffect_input="bold"
##==============================================================================
## BEHAVIOR
##==============================================================================
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
enable_command_on_new_line=false # Add new line between prompt and command




Expand Down
6 changes: 4 additions & 2 deletions config/examples/synth-shell-prompt.red.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ texteffect_input="bold"
##==============================================================================
## BEHAVIOR
##==============================================================================
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
enable_command_on_new_line=false # Add new line between prompt and command




Expand Down
6 changes: 4 additions & 2 deletions config/examples/synth-shell-prompt.yellow.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ texteffect_input="bold"
##==============================================================================
## BEHAVIOR
##==============================================================================
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
enable_vertical_padding=true # Add extra new line over prompt
enable_command_on_new_line=false # Add new line between prompt and command




Expand Down
11 changes: 6 additions & 5 deletions config/synth-shell-prompt.config.default
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
##==============================================================================
format="USER HOST PWD GIT PYENV TF KUBE"

separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
separator_padding_left='' # Add char or string to the left of the separator
separator_padding_right='' # Add char or string to the right of the separator
segment_padding=' ' # Add char or string around segment text
enable_vertical_padding=true # Add extra new line over prompt
separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
separator_padding_left='' # Add char or string to the left of the separator
separator_padding_right='' # Add char or string to the right of the separator
segment_padding=' ' # Add char or string around segment text
enable_vertical_padding=true # Add extra new line over prompt
enable_command_on_new_line=false # Add new line between prompt and command



Expand Down
Binary file added doc/next_line_command.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions synth-shell-prompt/synth-shell-prompt.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ prompt_command_hook()
## INPUT formatting.
## Notice that this reuses the PS1 variables over and over again, and appends
## all extra formatting elements to the end of it.
PS1="${titlebar}${SSP_VERTICAL_PADDING}"
PS1="${titlebar}${SSP_VERTICAL_PADDING}${SSP_NEW_LINE_LINK_TOP}"
while [ "${#elements[@]}" -gt 1 ]; do
local current=${elements[0]}
local next=${elements[1]}
Expand All @@ -386,7 +386,11 @@ prompt_command_hook()
local input_bg=${input_colors[1]}
local input_effect=${input_colors[2]}
local input_format="\[$(getFormatCode -c $input_color -b $input_bg -e $input_effect)\]"
PS1="$PS1 $input_format"
local command_start_symbol="${input_format}${SSP_BASH_SYMBOL}"

## the prompt is then the prompt we build above, the separation between prompt and command and in
## the case of a new line inbetween, the corresponding link and $ symbol to start the command.
PS1="${PS1}${SSP_PROMPT_COMM_SEP}${SSP_NEW_LINE_LINK_BOTTOM}${command_start_symbol} $input_format"


## Once this point is reached, PS1 is formatted and set. The terminal session
Expand Down Expand Up @@ -422,6 +426,19 @@ prompt_command_hook()
local vertical_padding=""
fi

## NEW LINE
if $enable_command_on_new_line; then
local new_line_link_top=""
local new_line_link_bottom=""
local prompt_command_separation="\n"
local bash_symbol="\$"
else
local new_line_link_top=""
local new_line_link_top=""
local prompt_command_separation=""
local bash_symbol=""
fi


## CONFIG FOR "prompt_command_hook()"
SSP_ELEMENTS=($format "INPUT") # Append INPUT to elements that have to be shown
Expand All @@ -435,6 +452,10 @@ prompt_command_hook()
SSP_COLORS_CLOCK=($font_color_clock $background_clock $texteffect_clock)
SSP_COLORS_INPUT=($font_color_input $background_input $texteffect_input)
SSP_VERTICAL_PADDING=$vertical_padding
SSP_NEW_LINE_LINK_TOP=$new_line_link_top
SSP_NEW_LINE_LINK_BOTTOM=$new_line_link_bottom
SSP_PROMPT_COMM_SEP=$prompt_command_separation
SSP_BASH_SYMBOL=$bash_symbol
SSP_MAX_PWD_CHAR=${max_pwd_char:-25}
SSP_PWD_TRUNC_SYMBOL=${pwd_trunc_symbol:-"..."}

Expand Down

0 comments on commit 91ced85

Please sign in to comment.