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

32 lines
667 B
Bash
Raw Normal View History

2022-09-18 14:36:46 -05:00
#!/usr/bin/env bash
2022-04-07 19:41:00 -05:00
# dictionary
define(){
dict -d gcide "$1" | bat
}
# thesaurus
synonym(){
dict -d moby-thesaurus "$1" | bat
}
# mount with user permissions
mmount(){
2022-09-18 14:36:46 -05:00
sudo mount -o uid="$(whoami)",gid="$(whoami)" "/dev/$1" "/mnt/$2"
2022-04-07 19:41:00 -05:00
}
# easy ssh-agent persistence
function ssha() {
2022-09-18 14:36:46 -05:00
test=$(ps -ef | grep '\sssh-agent$' | grep -v grep | awk '{print $2}' | xargs)
2022-04-07 19:41:00 -05:00
if [ "$test" = "" ]; then
2022-09-18 14:36:46 -05:00
if [ -e ~/.ssh-agent.sh ]; then
2022-04-07 19:41:00 -05:00
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