mirror of
https://github.com/nikdoof/dotfiles.git
synced 2025-12-14 10:12:28 +00:00
52 lines
1.2 KiB
Bash
52 lines
1.2 KiB
Bash
# Git pulls latest dotfiles
|
|
function update-dotfiles() {
|
|
prevdir=$PWD
|
|
if [ -d "${HOME}/.dotfiles" ]; then
|
|
cd $HOME/.dotfiles
|
|
git pull --rebase --autostash
|
|
fi
|
|
if [ -d "${HOME}/.dotfiles-private" ]; then
|
|
cd $HOME/.dotfiles-private
|
|
git pull --rebase --autostash
|
|
fi
|
|
cd $prevdir
|
|
}
|
|
|
|
# Wrapper around ssh-add to ease usage and also ensure basic timeouts
|
|
function add-sshkey() {
|
|
TIMEOUT="2h"
|
|
NAME=$1
|
|
|
|
if [ -z "$NAME" ]; then
|
|
echo "Current Agent Keys"
|
|
ssh-add -L | cut -d" " -f 3-
|
|
else
|
|
if [ -f "${HOME}/.ssh/id_ed25519_${NAME}" ]; then
|
|
ssh-add -t $TIMEOUT "${HOME}/.ssh/id_ed25519_${NAME}"
|
|
else
|
|
echo "No key named ${NAME} found..."
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Switch to a simple prompt for demos (thanks Mark H for the idea)
|
|
function demoprompt() {
|
|
if [ ! -z ${OLDPS1+x} ]; then
|
|
PS1=$OLDPS1
|
|
unset OLDPS1
|
|
else
|
|
OLDPS1=$PS1
|
|
PS1=" %# "
|
|
clear
|
|
fi
|
|
}
|
|
|
|
# Tag the file as OK to run
|
|
function itsok() {
|
|
if [[ $(uname) == "Darwin" ]]; then
|
|
xattr -d com.apple.quarantine $1
|
|
else
|
|
echo 'This only works on macOS...'
|
|
fi
|
|
}
|