skynet/shell/bashrc.d/03-functions.sh

32 lines
667 B
Bash

#!/usr/bin/env bash
# dictionary
define(){
dict -d gcide "$1" | bat
}
# thesaurus
synonym(){
dict -d moby-thesaurus "$1" | bat
}
# mount with user permissions
mmount(){
sudo mount -o uid="$(whoami)",gid="$(whoami)" "/dev/$1" "/mnt/$2"
}
# easy ssh-agent persistence
function ssha() {
test=$(ps -ef | grep '\sssh-agent$' | grep -v grep | awk '{print $2}' | xargs)
if [ "$test" = "" ]; then
if [ -e ~/.ssh-agent.sh ]; then
rm -f ~/.ssh-agent.sh
fi
ssh-agent | grep -v echo >&~/.ssh-agent.sh
fi
test -e ~/.ssh-agent.sh && source ~/.ssh-agent.sh
ssh-add -l > /dev/null || ssh-add
}
test -e ~/.ssh-agent.sh && source ~/.ssh-agent.sh