summaryrefslogtreecommitdiff
path: root/.shinit
blob: 2ee29f9577c142e3cb84b01866202ca110655d79 (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
# -*- mode: sh -*-

if [ "$DESKTOP_SESSION" = i3 -o "$XDG_CURRENT_DESKTOP" = sway ] \
       && command -v emacs >/dev/null; then
    EDITOR="emacsclient -c"; VISUAL="$EDITOR"
fi

ls --version 2>/dev/null | grep -q "GNU coreutils" \
    && alias ls="ls --color=auto --literal --classify"
grep --version 2>/dev/null | grep -q "GNU grep" \
    && alias grep="grep --color=auto"

alias doas="doas "
alias sudo="sudo "

alias e="$EDITOR"
alias d="emacsclient -te '(dired \".\")'"
alias ta="tmux new-session -A -s default -c ~"
alias rax="screen -URaAx"
alias mrs="src-register-all && mr -m status"
alias gdbmacs="emacsclient -tc -sgdbmacs"
alias g="git"
alias ga="git annex"
alias a2ac="annex-to-annex --commit"
# useful to check whether a rebase introduced any changes to files
alias rld="git diff @{1}..@{0}"
alias athvpn="sshuttle -r athena 0/0 --dns"
alias grepcopy="grep --color=always -Eir '(copyright|©)' * | less -R"
alias dlp="lp -o sides=two-sided-long-edge"
alias arsync="rsync -aSHAXc --partial --numeric-ids --info=progress2"
alias axrsync="rsync -aSHAXxc --partial --numeric-ids --info=progress2"
# To have a terminal emulator exit upon remote tmux detach, like my C-i s.
alias sshta="exec ssh-and-tmux"
alias pdd="dd bs=4M status=progress conv=fdatasync"

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/no-start --spw/update-environment
    emacsclient -sgdbmacs --spw/no-start --spw/update-environment
}

#### Host-specific: 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 arguments like -t.
        if [ -n "$1" ]; then
            VISUAL=emacsclient dak process-new "$1"*changes
        else
            VISUAL=emacsclient dak process-new -b
        fi
    }
fi