Última actividad 1 month ago

Revisión c5f8b9caaf39c3da7b90cb048d39b2713dc4d976

.bash_prompt Sin formato
1################################################################################
2# -------------------------
3# BASH PROMPT CONFIGURATION
4# -------------------------
5# Description:
6# Shows a nicer bash prompt:
7# ▶ 🖳 mypc ▶ documents ▶ ⎇ master ▶ 𝍠 ✔
8# -------- --------- ---------- --- -----
9# | | | | |
10# hostname folder git branch jobs last command result
11#
12# See https://gist.github.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514#file-prompt_demo-png
13# for a colurful demo.
14#
15# Last version of this file can be found at
16# https://gist.github.com/DavidEGx/7b8d378d55ec03aeefe86e5135ef8514
17#
18# Usage:
19# 1. Get a copy of __git_ps1
20# wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh
21# 2. Copy this file in your local diretory as ~/.bash_prompt
22# 3. Edit your ~/.bashrc and add this line:
23# . ~/.bash_prompt
24# 4. Reload your ~/.bashrc:
25# . ~/.bashrc
26#
27# Requires:
28# * Some unicode font
29# * 256 colors support in your terminal
30# * __git_ps1
31#
32# Useful info:
33# * http://misc.flogisoft.com/bash/tip_colors_and_formatting
34# * https://github.com/morhetz/gruvbox
35# * https://gist.github.com/MicahElliott/719710
36#
37################################################################################
38
39#######################
40# Git config
41#######################
42# Need to get git-prompt:
43# wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh
44if [ -f ~/.git-prompt.sh ]; then
45 . ~/.git-prompt.sh
46fi
47GIT_PS1_SHOWDIRTYSTATE=""
48GIT_PS1_SHOWCOLORHINTS=""
49GIT_PS1_SHOWUNTRACKEDFILES=""
50GIT_PS1_SHOWUPSTREAM=""
51GIT_PS1_SHOWSTASHSTATE=""
52
53#######################
54# Colors
55#######################
56
57# Color reset
58PLAIN='\e[0m'
59
60# Text colors
61RED='\[\e[31m\]'
62GREEN='\[\e[32m\]'
63BLUE='\e[1;38;5;25m'
64LIGHTGRAY='\e[1;38;5;252m'
65GRAY='\e[1;38;5;242m'
66WHITE='\e[1;38;5;251m'
67ORANGE='\[\e[1;38;5;130m\]'
68BOLDBLACK='\e[1;38;5;232m'
69
70# Background colors
71BGBLACK='\e[40m'
72BGBLUE='\e[48;5;25m'
73BGLIGHTGRAY='\e[48;5;252m'
74BGGRAY='\e[48;5;242m'
75
76#######################
77# Icons (I_ICON_NAME)
78#######################
79I_ARROW="▶"
80#I_HOST=" 💻 " This character casues some issues
81I_HOST=" 🖳 "
82I_GIT=" ⎇ "
83I_OK="✔"
84I_KO="✖️"
85
86#######################
87# Styles (S_STYLE_NAME)
88#######################
89S_HOST_BG=$BGLIGHTGRAY
90S_HOST_TXT=$BOLDBLACK
91S_HOST_ARROW=$GRAY
92S_DIR_BG=$BGGRAY
93S_DIR_TXT=$LIGHTGRAY
94S_GIT_BG=$BGBLUE
95S_GIT_TXT=$WHITE
96S_GIT_ARROW=$GRAY
97S_TASK_BG=$BGBLACK
98S_TASK_TXT=$ORANGE
99S_TASK_ARROW=$BLUE
100S_RESULT_OK=$GREEN
101S_RESULT_KO=$RED
102
103#######################
104# Prompt parts (P_*)
105#######################
106P_HOST=`printf "\[$S_HOST_BG\]\[$S_HOST_ARROW\]$I_ARROW\[$S_HOST_TXT\] $I_HOST\h "`
107P_DIR=`printf "\[$S_DIR_BG\]\[$S_DIR_TXT\]$I_ARROW \W "`
108P_GIT='
109 P_GIT_BRANCH=\`type __git_ps1 >/dev/null 2>&1 && __git_ps1 %s\`
110 if [ -z $P_GIT_BRANCH ]; then
111 echo -en " \[$S_TASK_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] ";
112 else
113 echo -en " \[$S_GIT_BG\]\[$S_GIT_ARROW\]$I_ARROW\[$S_GIT_TXT\]$I_GIT $P_GIT_BRANCH \[$S_TASK_BG\]\[$S_TASK_ARROW\]$I_ARROW\[$PLAIN\] ";
114 fi
115'
116# Number of jobs running
117P_JOBS=`printf "
118 echo -n '\[$TASK_TXT\]'
119 case '\j' in
120 0) echo -n '';;
121 1) echo -n '𝍠 ' ;;
122 2) echo -n '𝍡 ' ;;
123 3) echo -n '𝍢 ' ;;
124 4) echo -n '𝍣 ' ;;
125 *) echo -n '𝍤 ' ;;
126 esac
127 echo -n '\[$PLAIN\]'
128"`
129# Result of the last command
130P_CMD_RESULT="
131 if [ \$LASTCMD -eq 0 ]; then
132 echo -n ${RESULT_OK}${I_OK}\[$PLAIN\];
133 else
134 echo -n ${RESULT_KO}${I_KO}\[$PLAIN\];
135 fi
136 echo -n ' '
137"
138
139PROMPT_COMMAND='LASTCMD=$? PS1="${debian_chroot:+($debian_chroot)}${P_HOST}${P_DIR}\`${P_GIT}\`\`${P_JOBS}\`\`${P_CMD_RESULT}\` "'
140
prompt_demo.png Sin formato
prompt_demo.png