summaryrefslogtreecommitdiffstats
path: root/dotfiles/bashrc
blob: 472a267c425e7a96248bddb721013fda1125427a (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
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# User specific aliases and functions

if [ -f /etc/bash_completion ]; then
  . /etc/bash_completion
fi

HISTSIZE=5000
export HISTSIZE
shopt -s histappend

UNFUCK_BASH_HISTORY="history -a"
if test -z "$PROMPT_COMMAND"; then
   PROMPT_COMMAND="$PROMPT_COMMAND;$UNFUCK_BASH_HISTORY"
else
   PROMPT_COMMAND="$UNFUCK_BASH_HISTORY"
fi   

EDITOR="emacsclient"
export EDITOR

_format_wd ()
{
  pwd=$(pwd)
  base=$(basename "$pwd")
  parent=$(basename $(dirname "$pwd")) 
  pparent=$(basename $(dirname "$parent")) 
  if test "$pparent" != "/"; then
    echo -n "$parent/";
    echo -n "$base";
  else 
    if test "$parent" != "/"; then
      echo -n "/$parent/"
      echo -n "$base";
    else
      echo -n "/";
      echo -n "$base";
    fi
  fi
}

_format_inroot_dir ()
{
  if test -n "$INROOT_DIR"; then
    echo " [root=$INROOT_DIR]"
  else
    if test -n "$CERTIFIED_GNOMIE"; then
      echo " [jhbuild=$MONO_GAC_PREFIX]"
    fi
  fi
}

_format_uid ()
{
  if test $(id -u) = '0'; then
    echo -n " <"; echo -n "uid=0"; echo -n ">"; 
  fi
}

PS1_PREFIX='$(_format_wd)$(_format_uid)$(_format_inroot_dir)'
if test -n "$BASH_COMPLETION" && test -f /etc/bash_completion.d/git; then
  PS1_PREFIX="$PS1_PREFIX"'$(__git_ps1 " [git %s]")'
fi

PS1="$PS1_PREFIX"'\n\$ '
export PS1