summaryrefslogtreecommitdiff
path: root/.bashrc
blob: b2befda2de99bf1b9f1d145c2ad28dffd0f0b45d (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# --- preferences

# load standard environment variables
. $HOME/.shenv

# '>' is a nice prompt char because it need not be followed by a
# space.  It is easy to distinguish the command from the prompt.
#
# This satisfies both `shell-prompt-pattern' and `tramp-shell-prompt-pattern'.
PS1='$(exit_code=$?; test $exit_code -eq 0 \
    || printf %s $exit_code " ")${debian_chroot:+($debian_chroot)}\u@\h:\w>'

case "$TERM" in
    # if this is an xterm set its title to user@host:dir
    # (this doesn't stop the likes of ncmpcpp setting a title)
    xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h:\w\a\]\[\e[1m\]$PS1\[\e[0m\]"
	;;
    80-column|dumb|unknown) ;;
    *) PS1="\[\e[1m\]$PS1\[\e[0m\]" ;;
esac

# enable better completion
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# history settings
HISTCONTROL=ignorespace:ignoredups
HISTSIZE=5000
HISTFILESIZE=5000
HISTIGNORE="ls" # colon-separated
shopt -s histappend

# make less more friendly for non-text input files; see lesspipe(1)
if [ -x /usr/bin/lesspipe ]; then
    eval "$(lesspipe)"
fi

. $HOME/.bash_defns

# --- aliases

alias ls="ls --color=auto --literal --classify"
alias grep="grep --colour=auto"

alias e="$EDITOR"
alias d="emacsclient -cne '(dired \".\")' >/dev/null"
# alias m="emacsclient -c -n -e '(progn (magit-status \".\") \
#  (delete-other-windows))' >/dev/null"
alias ta="tmux new-session -A -s default"
alias rax="screen -URaAx"
alias new-login-shell="exec su -l $USER" # get new UNIX group without relog
alias mrs="src-register-all && mr -m status"
alias gdbmacs="emacsclient -tc -sgdbmacs"

alias b="bts --mbox show"

# alias develacc='sudo machinectl shell spw@develacc \
#       $(sudo enter-develacc /bin/sh -c "getent passwd spw | cut -d: -f7")'
# alias develaccr='sudo machinectl shell root@develacc \
#       $(sudo enter-develacc /bin/sh -c "getent passwd root | cut -d: -f7")'

# --- more powerful aliases built with shell functions

secs () {
    for i in $(seq $1 -1 1); do
        echo $i
        sleep 1
    done
    echo 0
}

upenv () {
    # don't want to do this outside of tmux as then tmux show-environment will
    # show values for the 'default' session which may be irrelevant to us
    if [ -n "$TMUX" ]; then
       local IFS=$'\n'
       for var in $(tmux show-environment | grep -v "^-"); do
	   eval "export \"$var\""
       done
    fi
    emacsclient --spw/update-environment
    emacsclient -sgdbmacs --spw/update-environment
}

# --- host-specific aliases/functions

# ftp-master.debian.org

if [ -d "/srv/ftp-master.debian.org" ]; then
    alias newlocks="cd /srv/ftp-master.debian.org/lock/new/ && ls -l"
    newlock () {
        touch /srv/ftp-master.debian.org/lock/new/"$1"
    }

    newunlock () {
        rm /srv/ftp-master.debian.org/lock/new/"$1"
    }

    pn () {
        cd /srv/ftp-master.debian.org/queue/new
        # we need VISUAL=emacsclient because dak's utils.call_editor
        # fails when VISUAL contains both the editor's name and some
        # arguments to it, as mine does
        if [[ $1 ]]; then
            VISUAL=emacsclient dak process-new "$1"*changes
        else
            VISUAL=emacsclient dak process-new -b
        fi
    }
fi