-
Notifications
You must be signed in to change notification settings - Fork 0
/
.nmgc_profile
86 lines (69 loc) · 2.84 KB
/
.nmgc_profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File containing commands to be added to the Bash profile.
# The script configure_nmgc.py will do this, or the uninstallation.
# the $nmgc command is defined directly in the .bash_profile by configure_nmgc.py
# Warning ! This prevent from using the 'nmgc' browser, common in all gnome environement.
## Thus, 'nmgc' will launch the file browser, and NOT the code. Be careful about that in GNU/Linux environments
alias nmgc_code="$nmgc/nmgc"
alias nmgc_outputs="$nmgc/nmgc_outputs"
alias nmgc_rates="$nmgc/nmgc_rates"
alias nmgc_major_reactions="$nmgc/nmgc_major_reactions"
alias nmgc_trace_major="$nmgc/nmgc_trace_major"
# Python scripts will be available in any folder
export PATH=$PATH:$nmgc/scripts:.
git_branch_name_prompt() {
# Only do this if the current directory is a git repository
if git status 2>/dev/null 1>/dev/null ; then
# We keep only the first line, then the last word is our branch
git_status_output=$(git status 2> /dev/null|head -1) || return
branch_name() {
# We get the last word with grep
echo "$git_status_output"|grep -oE '[^ ]+$'
}
echo "($(branch_name))"
fi
}
git_branch_colour_prompt() {
# Only do this if the current directory is a git repository
if git status 2>/dev/null 1>/dev/null ; then
git_status_output=$(git status 2> /dev/null) || return
find_pattern_in_status() {
local pattern="$1"
[[ "$git_status_output" =~ ${pattern} ]]
}
is_clean() {
local clean_fr='(rien à valider, la copie de travail est propre)'
local clean_en='(working directory clean)'
find_pattern_in_status "($clean_fr|$clean_en)"
}
is_local_changes() {
local added_fr='Modifications qui seront validées :'
local not_added_fr='Modifications qui ne seront pas validées :'
local added_en='# Changes to be committed'
local not_added_en='# Changes not staged for commit'
find_pattern_in_status "($added_fr|$not_added_fr|$added_en|$not_added_en)"
}
is_untracked() {
local untracked_fr='Fichiers non suivis:'
local untracked_en='# Untracked files'
find_pattern_in_status "($untracked_fr|$untracked_en)"
}
# local bold="\033[1m"
local no_colour="\033[0m"
local red="\033[31m"
local green="\033[32m"
local yellow="\033[33m"
local branch_colour=""
if is_untracked
then
branch_colour=$red
elif is_local_changes
then
branch_colour=$yellow
elif is_clean
then
branch_colour=$green
fi
echo -e "$branch_colour"
fi
}
PS1="\h.\u:\[\033[35m\]\W\[\033[0m\]\[\$(git_branch_colour_prompt)\]\$(git_branch_name_prompt)\[\033[0m\]\$ "