From c67d4836f4d6d5e6c8ef4e2de38bd21ccb6ee1a1 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 23 Nov 2022 23:35:59 -0700 Subject: tidy and simplify shell init Rely on SPWCRONTAB property to set PATH for cronjobs, and otherwise rely on .profile, .xsessionrc etc. to set PATH, once, at login. Just archive scripts I haven't used lately which might otherwise need more significant adjustments, or appear to be broken in other ways. --- .shinit | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .shinit (limited to '.shinit') diff --git a/.shinit b/.shinit new file mode 100644 index 00000000..4201f08b --- /dev/null +++ b/.shinit @@ -0,0 +1,61 @@ +# -*- 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 e="$EDITOR" +alias d="emacsclient -te '(dired \".\")'" +alias ta="tmux new-session -A -s default" +alias rax="screen -URaAx" +alias mrs="src-register-all && mr -m status" +alias gdbmacs="emacsclient -tc -sgdbmacs" +alias g="git" +alias ga="git annex" +# 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" + +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: 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 -- cgit v1.2.3