2022-01-15 19:00:35 +09:00
#! bash oh-my-bash.module
2017-10-10 18:07:01 +07:00
# This is combination of works from two different people which I combined for my requirement.
# Original PS1 was from reddit user /u/Allevil669 which I found in thread: https://www.reddit.com/r/linux/comments/1z33lj/linux_users_whats_your_favourite_bash_prompt/
# I used that PS1 to the bash-it theme 'morris', and customized it to my liking. All credits to /u/Allevil669 and morris.
#
# prompt theming
2022-01-08 14:35:55 +09:00
_omb_module_require plugin:battery
2022-01-11 12:40:43 +09:00
function _omb_theme_PROMPT_COMMAND( ) {
2022-01-08 14:42:53 +09:00
local status = $?
# added TITLEBAR for updating the tab and window titles with the pwd
local TITLEBAR
case $TERM in
xterm* | screen)
TITLEBAR = $'\1\e]0;' $USER @${ HOSTNAME %%.* } :${ PWD /# $HOME /~ } $'\e\\\2' ; ;
*)
TITLEBAR = ; ;
esac
local SC
if ( ( status = = 0) ) ; then
2022-01-19 16:52:15 +09:00
SC = " $_omb_prompt_cyan - $_omb_prompt_bold_green ( ${ green } ^_^ $_omb_prompt_bold_green ) " ;
2022-01-08 14:42:53 +09:00
else
2022-01-19 16:52:15 +09:00
SC = " $_omb_prompt_cyan - $_omb_prompt_bold_green ( ${ red } T_T $_omb_prompt_bold_green ) " ;
2022-01-08 14:42:53 +09:00
fi
local BC = $( battery_percentage)
[ [ $BC = = no && $BC = = -1 ] ] && BC =
2022-01-19 16:52:15 +09:00
BC = ${ BC : + ${ _omb_prompt_cyan } - ${ green } ( $BC %) }
2022-01-08 14:42:53 +09:00
2022-01-19 16:52:15 +09:00
PS1 = $TITLEBAR " \n ${ _omb_prompt_cyan } ┌─ ${ _omb_prompt_bold_white } [\u@\h] ${ _omb_prompt_cyan } ─ ${ _omb_prompt_bold_yellow } (\w) $( scm_prompt_info) \n ${ _omb_prompt_cyan } └─ ${ _omb_prompt_bold_green } [\A] $SC $BC ${ _omb_prompt_cyan } - ${ _omb_prompt_bold_cyan } [ ${ green } ${ _omb_prompt_bold_green } \$ ${ _omb_prompt_bold_cyan } ] ${ green } "
2017-10-10 18:07:01 +07:00
}
# scm theming
SCM_THEME_PROMPT_DIRTY = " ${ red } ✗ "
2022-01-19 16:52:15 +09:00
SCM_THEME_PROMPT_CLEAN = " ${ _omb_prompt_bold_green } ✓ "
SCM_THEME_PROMPT_PREFIX = " ${ _omb_prompt_bold_cyan } ( "
SCM_THEME_PROMPT_SUFFIX = " ${ _omb_prompt_bold_cyan } ) ${ _omb_prompt_reset_color } "
2017-10-10 18:07:01 +07:00
2022-01-11 12:40:43 +09:00
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND