~ashn/setup

ref: 8e2f93a7f7c6b0120c138b8ccb00f04f531613b7 setup/dotfiles/.shrc -rw-r--r-- 1.8 KiB
8e2f93a7ashn Add l1 alias to .shrc 1 year, 4 months ago
                                                                                
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
#!/bin/sh
# .shrc : Common sh-compatible run commands.

[ -f "$HOME/.env" ] && . "$HOME/.env"


## ALIASES
alias ll='ls -alF'
alias l1='ls -a1'
alias ccc='clear;clear;clear'
alias tree='tree -n'
alias now='echo `date +%R` "/" `date +%r`'
alias clock='while true; do clear; now; sleep 1; done'

alias shelve='git stash'
alias unshelve='git stash apply'

alias valgrind-mc='valgrind \
    --leak-check=yes \
    --leak-check=full \
    --show-leak-kinds=all \
    --track-origins=yes'
alias gdbt='gdb --tui'


## CUSTOM PS1
git_ps1() {
    GIT_BRANCH=$(git branch 2> /dev/null | grep '^\* ' | sed -e 's/^\* //g')
    if [ -z "${GIT_BRANCH}" ]; then
        echo ''
        return
    fi

    GIT_STATUS=$(git status 2> /dev/null | tee)
    GIT_REN=$(echo "${GIT_STATUS}" | grep '^.*renamed:')
    GIT_MOD=$(echo "${GIT_STATUS}" | grep '^.*modified:')
    GIT_DEL=$(echo "${GIT_STATUS}" | grep '^.*deleted:')
    GIT_NEW=$(echo "${GIT_STATUS}" | grep '^.*new file:')
    GIT_UNT=$(echo "${GIT_STATUS}" | grep '^Untracked files')

    GIT_STATUS_SUMMARY=''
    if [ -n "${GIT_REN}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}>"
    fi
    if [ -n "${GIT_MOD}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}!"
    fi
    if [ -n "${GIT_DEL}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}x"
    fi
    if [ -n "${GIT_NEW}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}+"
    fi
    if [ -n "${GIT_UNT}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}?"
    fi

    if [ ! -z "${GIT_STATUS_SUMMARY}" ]; then
        echo "[${GIT_BRANCH} ${GIT_STATUS_SUMMARY}]"
    else
        echo "[${GIT_BRANCH}]"
    fi
}
ps1() {
    if [ -z "$BASH_VERSION" ]; then
        echo "$(pwd)$ "
        return 0
    fi
    echo "\w\[\e[33m\]\`git_ps1\`\[\e[m\]\\$ "
}

export git_ps1
export PS1="$(ps1)"