1
0
Fork 0
mirror of https://github.com/MillironX/dotfiles.git synced 2024-12-22 17:08:16 +00:00

Move aliases to their own file

This commit is contained in:
Thomas A. Christensen II 2021-08-24 19:46:22 -05:00
parent a28e633792
commit 3d57e32014
3 changed files with 32 additions and 35 deletions

30
dot_aliases Normal file
View file

@ -0,0 +1,30 @@
# Only create aliases if the underlying programs are available
# This allows portability between machines in different states
alias_if_exists () {
ALIAS=${1}
COMMAND=${2}
ARGS=${3}
if [ $(command -v $COMMAND) ]; then
if [ -n "$ARGS" ]; then
alias $ALIAS="$COMMAND $ARGS"
else
alias $ALIAS="$COMMAND"
fi
fi
}
# Context-sensitive aliases
alias_if_exists config git '--git-dir=$HOME/.cfg/ --work-tree=$HOME'
alias_if_exists bat batcat
alias_if_exists cat bat
alias_if_exists ls lsd
# Universal aliases
alias please='sudo $(fc -ln -1)'
alias nrun='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus="NVIDIA_only"'
# Alias-like functions
nd () {
mkdir "$1"
cd "$1"
}

View file

@ -16,6 +16,7 @@ export PATH
# export SYSTEMD_PAGER=
# User specific aliases and functions
source $HOME/.aliases
# Make the prompt pretty, just in case we're stuck in bash land
export PS1="[\[\e[32m\]\u\[\e[m\]@\[\e[33m\]\h\[\e[m\] \[\e[34m\]\W\[\e[m\]] \\$ "

View file

@ -127,56 +127,22 @@ if [ ! -n "$SSH_CONNECTION" ]; then
ZLE_RPROMPT_INDENT=0
fi
# Personal aliases
alias zshconfig="$EDITOR ~/.zshrc"
alias ohmyzsh="$EDITOR ~/.oh-my-zsh"
alias zshrefresh="source ~/.zshrc"
# Dotfiles sync command
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
# Check for Ubuntu's name for bat
if [[ $(command -v batcat) ]]; then
alias bat="batcat"
fi
source $HOME/.aliases
# Replace cat with bat
if [[ $(command -v bat) ]]; then
alias cat="bat"
export BAT_PAGER="less -RF"
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANROFFOPT="-c"
fi
# Replace ls with lsd
if [[ $(command -v lsd) ]]; then
alias ls="lsd"
fi
# Add notification support for long-running processes
if [[ $(command -v ntfy) ]]; then
eval "$(ntfy shell-integration --longer-than 30)"
export AUTO_NTFY_DONE_IGNORE="vim nano emacs zshconfig screen tmux ssh top htop less more most nethogs 'singularity shell' julia man"
fi
# Replace VSCode with pure FOSS alternative
if [[ $(command -v codium) ]] && [[ ! $(command -v code) ]]; then
alias code="codium"
fi
# Make forgetting sudo less painful
alias please='sudo $(fc -ln -1)'
# Make and change directories in one easy step
# nd = New Directory
nd () {
mkdir "$1"
cd "$1"
}
# Make running programs on the GPU less painful
alias nrun='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus="NVIDIA_only"'
# Set the Nextflow enviroment caches
export NXF_HOME="$HOME/.nextflow"
export NXF_CONDA_CACHEDIR="$NXF_HOME/conda"