mirror of https://github.com/Chizi123/Dotfiles.git

Joel Grunbaum
2025-02-02 91c55ffeff49ee1d2beb95faf9b301fe2c65348c
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
# Set bash history size
export HISTSIZE=10000
export HISTCONTROL=erasedups
shopt -s histappend
 
# Prompt, no colours to differentiate it from zsh
parse_git_repo() {
    git remote -v 2>/dev/null | sed -z 's/.*\/\(.*\)\.git.*/\1/g;'
}
 
parse_git_branch() {
    git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
 
parse_git_tag() {
    git describe --tags 2>/dev/null
}
 
git_prompt() {
    local ret="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
    if [ -z $ret ]; then
        return
    fi
    local OUT="$(parse_git_branch)"
    if [ "$OUT" == " (no branch)" ]; then
        OUT="($(parse_git_tag))"
    fi
    if [ -n "$OUT" ]; then
        OUT=" ($(parse_git_repo):$OUT)"
    fi
    echo "$OUT"
}
 
# PS1="[\u@\h \W]\$ "
PS1="[\u@\h\$(git_prompt) \W]\$ "
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
 
# Common completions
source ~/.commonshell
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] && source /usr/share/doc/pkgfile/command-not-found.bash
[ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion
 
# Ble.sh for syntax highlighting and shell completion
[ -r ${HOME}/.ble.sh ] && source ${HOME}/.ble.sh