Diferències
Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
Ambdós costats versió prèvia Revisió prèvia Següent revisió | Revisió prèvia | ||
linux:bash:ps1 [08/07/2018 00:19] – mate | linux:bash:ps1 [04/09/2018 05:59] (actual) – mate | ||
---|---|---|---|
Línia 1: | Línia 1: | ||
= PS1 | = PS1 | ||
== simples | == simples | ||
- | {{:misproyectos:clitools:pasted: | + | {{:linux:bash:ps1: |
<code bash> | <code bash> | ||
export PS1=" | export PS1=" | ||
</ | </ | ||
- | {{:misproyectos:clitools:pasted: | + | {{:linux:bash:ps1: |
<code bash> | <code bash> | ||
export PS1=" | export PS1=" | ||
Línia 12: | Línia 12: | ||
== soporte GIT | == soporte GIT | ||
+ | /vía: [[https:// | ||
+ | <code bash> | ||
+ | function we_are_in_git_work_tree { | ||
+ | git rev-parse --is-inside-work-tree &> /dev/null | ||
+ | } | ||
+ | |||
+ | function parse_git_branch { | ||
+ | if we_are_in_git_work_tree | ||
+ | then | ||
+ | local BR=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD 2> /dev/null) | ||
+ | if [ " | ||
+ | then | ||
+ | local NM=$(git name-rev --name-only HEAD 2> /dev/null) | ||
+ | if [ " | ||
+ | then echo -n " | ||
+ | else git rev-parse --short HEAD 2> /dev/null | ||
+ | fi | ||
+ | else | ||
+ | echo -n $BR | ||
+ | fi | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | function parse_git_status { | ||
+ | if we_are_in_git_work_tree | ||
+ | then | ||
+ | local ST=$(git status --short 2> /dev/null) | ||
+ | if [ -n " | ||
+ | then echo -n " + " | ||
+ | else echo -n " - " | ||
+ | fi | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | function pwd_depth_limit_2 { | ||
+ | if [ " | ||
+ | then echo -n " | ||
+ | else pwd | sed -e " | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | COLBROWN=" | ||
+ | COLRED=" | ||
+ | COLCLEAR=" | ||
+ | |||
+ | # export all these for subshells | ||
+ | export -f parse_git_branch parse_git_status we_are_in_git_work_tree pwd_depth_limit_2 | ||
+ | export PS1=" | ||
+ | export TERM=" | ||
+ | </ | ||
=== ejemplos y fuentes de ideas | === ejemplos y fuentes de ideas | ||
+ | funciones: [[https:// | ||
<code bash __git_ps1()> | <code bash __git_ps1()> | ||
export PS1=" | export PS1=" |