1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
common-configs/zsh/customizations/zsh_aliases.zsh

54 lines
1.9 KiB

#!/bin/zsh
# Install EDITOR
export EDITOR='nvim'
# Set up the vim config path
export VIM_CONFIG_DIR=$__COMMON_CONFIGS/vim
3 years ago
# Set the SSH auth sock to the central location
if [[ -n $SSH_AUTH_SOCK ]] && [[ $SSH_AUTH_SOCK != $HOME/.ssh/ssh_auth_sock ]]; then
ln -sf "$SSH_AUTH_SOCK" "$HOME/.ssh/ssh_auth_sock"
fi
export SSH_AUTH_SOCK="$HOME/.ssh/ssh_auth_sock"
# Set potentially-destructive commands to use interactive modes
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Use a larger number of KDF rounds and the secure ed25519 key type by default.
alias ssh-keygen="ssh-keygen -a 100 -b 4096 -t ed25519"
# Reload this file's (and other customizations') aliases.
function reload_zsh()
{
source "$HOME"/.zshrc
}
# Check if the git repository is fully synced.
# Pass --force-fetch to force the fetch to happen, even if one happened recently.
function __common_configs_in_sync() {
(
# Failure modes, in order:
# exit 9: Problem cd'ing or getting commit hashes - things that should never fail
cd $__COMMON_CONFIGS || exit 9
localCommit=$(git show-ref --verify --hash refs/heads/master) || exit 9
if [[ $1 == --force-fetch ]] || [[ ! -f .last-fetch ]] || [[ $(date --reference=.last-fetch +%s) -lt $(date --date='5 minutes ago' +%s) ]]; then
git fetch --quiet origin && touch .last-fetch
fi
remoteCommit=$(git show-ref --verify --hash refs/remotes/origin/master) || exit 9
# exit 1: master is not the commit which is checked out.
[[ $(git symbolic-ref HEAD) == "refs/heads/master" ]] || exit 1
# exit 2: master and origin/master are different.
[[ $localCommit == $remoteCommit ]] || exit 2
# exit 3: There are staged changes.
git diff-index --cached --exit-code --quiet HEAD || exit 3
# exit 4: There are unstaged changes.
git diff-files --exit-code --quiet HEAD || exit 4
)
}
# Enable built in help in the shell.
export HELPDIR=/usr/share/zsh/help
autoload run-help
alias help=run-help