File tree Expand file tree Collapse file tree 1 file changed +20
-19
lines changed
Expand file tree Collapse file tree 1 file changed +20
-19
lines changed Original file line number Diff line number Diff line change 1414#
1515
1616function _omb_theme_PROMPT_COMMAND() {
17-
1817 # Obtenemos IP segun el sistema operativo
1918 local IP
2019 case $OSTYPE in
21- linux-gnu)
22- IP=$( hostname -I | awk ' {print $1}' )
23- ;;
24- darwin* )
25- IP=$( ifconfig en0 | awk ' $1=="inet" {print $2}' )
26- ;;
27- * )
28- IP=" 127.0.0.1" # Default to localhost if OS is not recognized
29- ;;
20+ linux-gnu)
21+ # 2025-09-21 hostname is not a part of GNU/Linux. In fact, Arch Linux
22+ # does not include "hostname" by default.
23+ # https://www.reddit.com/r/arch/comments/1nlv59f/bash_hostname_commend_not_found/
24+ { IP=$( ip addr 2> /dev/null | awk ' $1 == "inet" {sub(/\/.*/, "", $2); if ($2 == "127.0.0.1") next; print $2; exit}' ) ; [[ $IP ]]; } ||
25+ { IP=$( ip addr 2> /dev/null | awk ' $1 == "inet6" {sub(/\/.*/, "", $2); if ($2 == "::1") next; print $2; exit}' ) ; [[ $IP ]]; } ||
26+ IP=$( hostname -I 2> /dev/null | awk ' {print $1}' )
27+ ;;
28+ darwin* )
29+ IP=$( ifconfig en0 | awk ' $1=="inet" {print $2}' )
30+ ;;
3031 esac
32+ [[ $IP ]] || IP=" 127.0.0.1" # Default to localhost if OS is not recognized
3133
3234 local HORA=$( date +%H)
33- local MERIDIANO
34- if (( 10 #$HORA > 12 )) ; then
35- MERIDIANO=" pm" ;
36- else
37- MERIDIANO=" am" ;
38- fi
39-
40- PS1=" \n${_omb_prompt_gray} \T${MERIDIANO} ${_omb_prompt_green} \u@$IP ${_omb_prompt_gray} \h ${_omb_prompt_olive} \$ {PWD} $( scm_prompt_info) \n${_omb_prompt_gray} \$ ${_omb_prompt_white} "
41-
35+ local MERIDIANO
36+ if (( 10 #$HORA > 12 )) ; then
37+ MERIDIANO=" pm" ;
38+ else
39+ MERIDIANO=" am" ;
40+ fi
41+
42+ PS1=" \n${_omb_prompt_gray} \T${MERIDIANO} ${_omb_prompt_green} \u@$IP ${_omb_prompt_gray} \h ${_omb_prompt_olive} \$ {PWD} $( scm_prompt_info) \n${_omb_prompt_gray} \$ ${_omb_prompt_normal} "
4243}
4344
4445SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown} ✗"
You can’t perform that action at this time.
0 commit comments