RSH 19: Working in shells and terminals

Our hacks and tricks in shells and terminals

Video

Collaborative notes taken during the session

Questions/comments

Anne

Richard

histsave() { history -a ; }
histread() { history -n ; history -n ; } # Needs it twice somehow...
histoff()  { HISTFILE=/dev/null ; }
cd_hook() {
    # This function handles a per-directory history file
    history -a
    command cd "$@" ;
    if [ -z "$PS1" -o -z "$HISTFILE" -o "$HISTFILE" = "/dev/null" ] ; then
        # Don't do histfile magic if not in interactive mode, HISTFILE
        # is unset or set to /dev/null
        return
    fi
    #if echo "$PWD" | grep "^$HOME" >> /dev/null && test -w . -a -O . -a -G .;
    #if test -w . -a -O . -a -G .;
    if test -w . ;
    then
        # Within home directory
        HISTFILE=./_bashhist
    else
        HISTFILE=~/.bash_history
    fi
}

alias cd=cd_hook
cd_hook $PWD
if [ "$PS1" -a x$_loaded_hist_once = x ] ; then
    history -r
    _loaded_hist_once=True
fi
if [ -n "$PS1" ] ; then
    for gitalias in $(git config --name-only --get-regex ^alias.) ; do
        #echo $gitalias
        gitalias="${gitalias#*.}"
        if ! type "$gitalias" &> /dev/null ; then
            eval alias "${gitalias}='git ${gitalias}'"
        fi
    done ; unset gitalias
fi

Roberto

I'll use the terminal in this binder instance

Radovan