Остання активність 1 month ago

Версія c955c3c96f5158c5e7350ad0f057031d8d409a89

.bash_prompt Неформатований
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="▶"
80I_HOST=" 💻 "
81I_GIT=" ⎇ "
82I_OK="✔"
83I_KO="✖️"
84
85#######################
86# Styles (S_STYLE_NAME)
87#######################
88S_HOST_BG=$BGLIGHTGRAY
89S_HOST_TXT=$BOLDBLACK
90S_HOST_ARROW=$GRAY
91S_DIR_BG=$BGGRAY
92S_DIR_TXT=$LIGHTGRAY
93S_GIT_BG=$BGBLUE
94S_GIT_TXT=$WHITE
95S_GIT_ARROW=$GRAY
96S_TASK_BG=$BGBLACK
97S_TASK_TXT=$ORANGE
98S_TASK_ARROW=$BLUE
99S_RESULT_OK=$GREEN
100S_RESULT_KO=$RED
101
102#######################
103# Prompt parts (P_*)
104#######################
105P_HOST=`printf "\[$S_HOST_BG\]\[$S_HOST_ARROW\]$I_ARROW\[$S_HOST_TXT\] $I_HOST\h "`
106P_DIR=`printf "\[$S_DIR_BG\]\[$S_DIR_TXT\]$I_ARROW \W "`
107P_GIT='
108 P_GIT_BRANCH=\`type __git_ps1 >/dev/null 2>&1 && __git_ps1 %s\`
109 if [ -z $P_GIT_BRANCH ]; then
110 echo -en " \[${S_TASK_BG}\]\[$S_GIT_ARROW\]$I_ARROW\[$PLAIN\] ";
111 else
112 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\] ";
113 fi
114'
115# Number of jobs running
116P_JOBS=`printf "
117 echo -n '${TASK_TXT}'
118 case '\j' in
119 0) echo -n '';;
120 1) echo -n '𝍠 ' ;;
121 2) echo -n '𝍡 ' ;;
122 3) echo -n '𝍢 ' ;;
123 4) echo -n '𝍣 ' ;;
124 *) echo -n '𝍤 ' ;;
125 esac
126 echo -n '\[$PLAIN\]'
127"`
128# Result of the last command
129P_CMD_RESULT="
130 if [ \$LASTCMD -eq 0 ]; then
131 echo -n ${RESULT_OK}${I_OK}\[$PLAIN\];
132 else
133 echo -n ${RESULT_KO}${I_KO}\[$PLAIN\];
134 fi
135 echo -n ' '
136"
137
138PROMPT_COMMAND='LASTCMD=$? PS1="${debian_chroot:+($debian_chroot)}${P_HOST}${P_DIR}\`${P_GIT}\`\`${P_JOBS}\`\`${P_CMD_RESULT}\` "'
139