Tech/Cozy things for your shell environments

From ~esantoro
Revision as of 12:59, 30 July 2024 by Esantoro (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

So in my current job I have to use a MacBook PRO for work. As most of the tools I use on a daily basis don't really work on Mac OS, I also have a remote virtual machine running GNU/Linux. I do a lot of stuff on this virtual machine, and over the last two years I've customized this environment for "comfort".

So in this page I want to collect this small improvements, aliases etc.

SSH agent

I want to configure the ssh agent once for boot and have it always keep my ssh keys in memory.

export SSH_AUTH_SOCK=/run/user/$UID/ssh-agent.sock
export SSH_AGENT_PID_FILE=/run/user/$UID/ssh-agent.pid
export SSH_AGENT_PID=$(cat $SSH_AGENT_PID_FILE 2>/dev/null)

function initssh {
    if [ ! -e $SSH_AUTH_SOCK ] ; then
        eval `ssh-agent -a /run/user/$UID/ssh-agent.sock`
        echo $SSH_AGENT_PID > $SSH_AGENT_PID_FILE
        ssh-add ~/.ssh/id_ecdsa
    fi
}

Multi-line prompt

I often have to work in long paths, and would like to always keep the full path visible as well as don't have a cluttered shell prompt

export PS1="[ \u@workbench: \w ]
\$ "

I don't manage my vm hostname, so i mask it and call the remote machine "workbench" in a fairly pragmatic manner.