aboutsummaryrefslogtreecommitdiffstats
path: root/home-dots/dot-bashrc
blob: 963fbec9c1e60dc07fd85a22287ea2216d7489d2 (plain)
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
#-*- mode: shell-script; -*-
#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# COLOR THEME
# Git branch in prompt.
git_current_branch() {
    local ref
    ref=$(git symbolic-ref --quiet HEAD 2>/dev/null)
    local ret=$?
    if [[ $ret != 0 ]]; then
        [[ $ret == 128 ]] && return # no git repo.
        ref=$(git rev-parse --short HEAD 2>/dev/null) || return
    fi
    echo "  ${ref#refs/heads/}"
}

function __prompt_command {
    # Must collect exit code very first thing
    # Just calculating git_branch changes the exit code
    local EXIT="$?"

    local red="\[\e[0;31m\]"
    local green="\[\e[0;32m\]"
    local yellow="\[\e[0;33m\]"
    local orange="\[\e[0;91m\]"
    local normal="\[\e[0m\]"
    local blue="\[\e[0;34m\]"

    PS1="\u@\h ${green}\w${blue}$(git_current_branch)"

    if [[ "${EXIT}" -ne 0 ]]; then
        PS1+=" ${red}✗ ${yellow}${EXIT}${orange}"
    else
        PS1+="${green}"
    fi
    PS1+=" ❯${normal} "
}
PROMPT_COMMAND=__prompt_command

# GPG agent with ssh
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
    export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi

export PATH="$HOME/.local/bin:$PATH"
alias isrun='ps -ae | grep'
alias gdimg='git difftool -t image_diff'
alias G='grep -i'
alias lar='ls -lahrt'
alias emacs='TERM=xterm-direct emacs'
alias mykeys='setxkbmap -I$HOME/.config/xkb/ oscar -option caps:escape -print | xkbcomp -I$HOME/.config/xkb/ - $DISPLAY'

[ -f "$HOME/.ghcup/env" ] && source "$HOME/.ghcup/env" # ghcup-env
source "$HOME/.cargo/env"
GUIX_PROFILE="$HOME/.guix-profile" && [ -e "$GUIX_PROFILE" ] && . "$GUIX_PROFILE/etc/profile" && export GUIX_LOCPATH=$GUIX_PROFILE/lib/locale
GUIX_PROFILE="$HOME/.config/guix/current" && [ -e "$GUIX_PROFILE" ] && . "$GUIX_PROFILE/etc/profile"
# export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
# export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
HISTSIZE=-1
HISTFILESIZE=-1