This is going to be a pretty run-of-the-mill alias/dotfile post since I don’t have anything very innovative in my aliases, but I needed some content to try out the jekyll blog feature ¯\_(ツ)_/¯.

Jupyter aliases

Usually, when I start a Jupyter server, I want it to be in the background. This one is pretty simple and just launches the server, piping stdout to /dev/null, and sending a sigtem when I’m done.

alias jn="jupyter notebook &>/dev/null &"
alias jl="jupyter lab &>/dev/null &"
alias js="pkill jupyter"

Open files

I use this one nearly every day. It works similarly to the Jupyter aliases, but uses xdg-open to open a file with my preferred application.

o() { xdg-open "$1" &>/dev/null & }

Renaming student submission files

Blackboard has a very annoying way of naming files. When I’m grading, I just want to see the student ID number (at NIU, a Z followed by 7 digits), plus any file extensions (even though they don’t really matter, but sometimes students submit an .ipynb and a .pdf or some other combination). I use this function to strip out all non-id or file extension characters in a filename.

bb-prefix() {
    case "$1" in
        "--preview" | "-p" )
            rename -n -e 's/^.*([Zz][0-9]{7}).*(\.\w*)$/$1$2/' * >&1
        ;;
        "--commit" | "-c")
            rename -e 's/^.*([Zz][0-9]{7}).*(\.\w*)$/$1$2/' * >&1
        ;;
        *)
            echo "Usage: bb-prefix [ -p --preview | -c --commit ]" >&2
        ;;
    esac
}

CSCI-680-Assignment1-NYE-Party_Z1234567_attempt_2017-12-31-23-59-59_theName TheStudentGaveIt.py becomes z1234567.py. Much nicer.

Those are the only cool aliases I use - the rest are fairly standard aliases for common git operations, ls, and similar tasks.