aboutsummaryrefslogtreecommitdiffstats
path: root/.kshrc
blob: 89d32d32eb626246fbde8e66716ea74642a9fa12 (plain) (blame)
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
# .kshrc is for interactive use.
case $- in
  *i*) ;;
  *)   return 0 2>/dev/null || exit 0 ;;
esac

PROMPT_TAIL='$'
[ "$(id -u)" -eq 0 ] && PROMPT_TAIL='#'

__prompt() {
    p=$PWD
    if [ "$p" = "$HOME" ]; then
      printf ' ~ '
    elif [ "$p" = / ]; then
      print ' / '
    else
      dir_b="${p%/*}"       # /home/user/projects
      dir_b="${dir_b##*/}"  # projects
      dir_a="${p##*/}"      # myfolder
      if [ "$dir_b" = "$USER" ]; then
        dir_b='~'
      fi
      result="$dir_b/$dir_a"
      printf " %s " $result
    fi

    br=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
    case "$br" in
        ''|HEAD) ;;
        *) printf "\033[32m(%s)\033[0m " "$br" ;;
    esac
    printf "$PROMPT_TAIL "
}
PS1='$(__prompt)'

export HISTFILE=~/.ksh_history
export HISTSIZE=1000000

alias gs="git status"
alias gc="git commit"
alias ga="git add"
alias gd="git diff"
alias gds="git diff --staged"
alias gp="git push"
alias gpo="git push origin"
alias gpl="git pull"
alias gplrb="git pull --rebase"
alias gl="git log"
alias gv="git log --graph --decorate --oneline"
alias gch="git checkout"
alias gcb="git checkout -b"

alias h="history 25"
alias j="jobs -l"
alias l="ls -al"

set -o emacs