Last active 1717407740

My custom .bashrc file, heavily inspired by Parrot's one.

Millefeuille revised this gist 1717407740. Go to revision

1 file changed, 2 insertions, 9 deletions

.bashrc

@@ -56,16 +56,11 @@ if [ -x /usr/bin/dircolors ]; then
56 56 fi
57 57
58 58 ###### Useful ENV ######
59 -
60 - # These ones are useful if you are a 42 student
61 - export USER="your42login"
62 - export GROUP="your42login"
63 - export MAIL="[email protected]"
64 59 # This one is not necessary, but quite useful for both the prompt and the CD command (you will see at the shopts)
65 60 export work="path to your main work folder"
66 61
67 62 # Here is the opportunity to add custom path folders
68 - PATH=/mnt/nfs/homes/mlabouri/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
63 + #PATH=
69 64
70 65 ###### Aliases ######
71 66
@@ -74,8 +69,6 @@ alias v2_norminette="~/norm/norminette.rb"
74 69 alias ll='ls -lh'
75 70 alias la='ls -lha'
76 71
77 - alias em='emacs -nw'
78 -
79 72 alias dd='dd status=progress'
80 73
81 74 alias _='sudo'
@@ -149,7 +142,7 @@ dashCharset="\342\224\200"
149 142 # This provides the current branch you are working in
150 143 gitStatus=""
151 144 function setGitStatus {
152 - git_status=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
145 + git_status=$(printf "%.10s" $(git rev-parse --abbrev-ref HEAD 2>/dev/null))
153 146 }
154 147
155 148 function psOne {

Millefeuille revised this gist 1694073323. Go to revision

1 file changed, 184 insertions

.bashrc(file created)

@@ -0,0 +1,184 @@
1 + ###### Color and Behavior ######
2 +
3 + case $- in
4 + *i*) ;;
5 + *) return;;
6 + esac
7 +
8 + # set a fancy prompt (non-color, unless we know we "want" color)
9 + case "$TERM" in
10 + xterm-color) color_prompt=yes;;
11 + esac
12 +
13 + # uncomment for a colored prompt, if the terminal has the capability; turned
14 + # off by default to not distract the user: the focus in a terminal window
15 + # should be on the output of commands, not on the prompt
16 + force_color_prompt=yes
17 +
18 + if [ -n "$force_color_prompt" ]; then
19 + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
20 + # We have color support; assume it's compliant with Ecma-48
21 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
22 + # a case would tend to support setf rather than setaf.)
23 + color_prompt=yes
24 + else
25 + color_prompt=
26 + fi
27 + fi
28 +
29 + # Set 'man' colors
30 + if [ "$color_prompt" = yes ]; then
31 + man() {
32 + env \
33 + LESS_TERMCAP_mb=$'\e[01;31m' \
34 + LESS_TERMCAP_md=$'\e[01;31m' \
35 + LESS_TERMCAP_me=$'\e[0m' \
36 + LESS_TERMCAP_se=$'\e[0m' \
37 + LESS_TERMCAP_so=$'\e[01;44;33m' \
38 + LESS_TERMCAP_ue=$'\e[0m' \
39 + LESS_TERMCAP_us=$'\e[01;32m' \
40 + man "$@"
41 + }
42 + fi
43 +
44 + unset color_prompt force_color_prompt
45 +
46 + # enable color support of ls and also add handy aliases
47 + if [ -x /usr/bin/dircolors ]; then
48 + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
49 + alias ls='ls -G --color=auto'
50 + alias dir='dir --color=auto'
51 + alias vdir='vdir --color=auto'
52 +
53 + alias grep='grep --color=auto'
54 + alias fgrep='fgrep --color=auto'
55 + alias egrep='egrep --color=auto'
56 + fi
57 +
58 + ###### Useful ENV ######
59 +
60 + # These ones are useful if you are a 42 student
61 + export USER="your42login"
62 + export GROUP="your42login"
63 + export MAIL="[email protected]"
64 + # This one is not necessary, but quite useful for both the prompt and the CD command (you will see at the shopts)
65 + export work="path to your main work folder"
66 +
67 + # Here is the opportunity to add custom path folders
68 + PATH=/mnt/nfs/homes/mlabouri/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
69 +
70 + ###### Aliases ######
71 +
72 + alias v2_norminette="~/norm/norminette.rb"
73 +
74 + alias ll='ls -lh'
75 + alias la='ls -lha'
76 +
77 + alias em='emacs -nw'
78 +
79 + alias dd='dd status=progress'
80 +
81 + alias _='sudo'
82 + alias _i='sudo -i'
83 + alias please='sudo'
84 + alias fucking='sudo'
85 +
86 + alias gcl='git clone'
87 +
88 + ###### shopts ######
89 +
90 + # enable programmable completion features
91 + if ! shopt -oq posix; then
92 + if [ -f /usr/share/bash-completion/bash_completion ]; then
93 + . /usr/share/bash-completion/bash_completion
94 + elif [ -f /etc/bash_completion ]; then
95 + . /etc/bash_completion
96 + fi
97 + fi
98 +
99 + # don't put duplicate lines or lines starting with space in the history.
100 + # See bash(1) for more options
101 + HISTCONTROL=ignoreboth
102 +
103 + # append to the history file, don't overwrite it
104 + shopt -s histappend
105 +
106 + # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
107 + HISTSIZE=1000
108 + HISTFILESIZE=2000
109 +
110 + # check the window size after each command and, if necessary,
111 + # update the values of LINES and COLUMNS.
112 + shopt -s checkwinsize
113 +
114 + # when using cd, corrects minor spelling errors
115 + shopt -s cdspell
116 +
117 + # "$<directory>" expands to "$cd <directory>"
118 + shopt -s autocd
119 +
120 + # if directory not found, treats argument as as variable (remember the work variable?)
121 + shopt -s cdable_vars
122 +
123 + # warns if jobs are running in background before exiting
124 + shopt -s checkjobs
125 +
126 + # do not autofill on empty line
127 + shopt -s no_empty_cmd_completion
128 +
129 + # Block > redir if overwrite happens, now needs to be >|
130 + set -C
131 +
132 + ###### Prompt and Term Title ######
133 +
134 + # Used colors
135 + red_c="\[\033[0;31m\]"
136 + end_c="\[\e[0m\]"
137 + white_c="\[\033[0;39m\]"
138 + yellow_c="\[\033[01;33m\]"
139 + blue_c="\[\033[01;96m\]"
140 + blue_oc="\[\033[0;96m\]"
141 + green_c="\[\033[0;32m\]"
142 +
143 + # Used charsets
144 + bottomCharset="\342\224\224\342\224\200\342\224\200\342\225\274"
145 + topCharset="\342\224\214\342\224\200"
146 + crossCharset="\342\234\227"
147 + dashCharset="\342\224\200"
148 +
149 + # This provides the current branch you are working in
150 + gitStatus=""
151 + function setGitStatus {
152 + git_status=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
153 + }
154 +
155 + function psOne {
156 + # Last process return value
157 + c_status=$?
158 + # Count number of running background jobs
159 + r_jobs=$(jobs | wc -l)
160 + # Count number of existing docker containers
161 + r_containers=$(docker ps -a 2>/dev/null | sed '1d' | wc -l)
162 +
163 + # Your path, with a replacement for HOME and work path
164 + path_r=$(pwd | sed "s|$HOME|~|" | sed "s|$work|work|")
165 + # Your current computer @42 (or just the hostname cut at the first dot)
166 + host_r=$(hostname | cut -d "." -f1 )
167 +
168 + setGitStatus
169 + # Random bullshit go, good luck with debugging
170 + PS1="$red_c$topCharset$(if [[ $c_status != 0 ]]; then echo "[$white_c$crossCharset$red_c]$dashCharset"; fi)"
171 + PS1+="$(if [[ $r_jobs != 0 ]]; then echo "[$white_c$r_jobs$red_c]$dashCharset"; fi)"
172 + PS1+="[$white_c\u$yellow_c@$blue_c\h$red_c]$dashCharset[$green_c$path_r$red_c]"
173 + PS1+="$(if [[ "$git_status" ]]; then echo "$dashCharset[$blue_c$git_status$red_c]"; fi)"
174 + PS1+="$(if [[ $r_containers != 0 ]]; then echo "$dashCharset<$blue_oc$r_containers$red_c>"; fi)"
175 + PS1+="\n$bottomCharset $yellow_c\$$end_c"
176 + }
177 +
178 + # Set ps1_sp to the title you want for your terminal
179 + function updateTitle {
180 + ps1_sp=$(echo "Hello!")
181 + echo -en "\033]0;$ps1_sp\a"
182 + }
183 +
184 + PROMPT_COMMAND='psOne'
Newer Older

Powered by Opengist ⋅ Load: 41ms