mirror of
https://github.com/MillironX/dotfiles.git
synced 2024-11-22 05:29:54 +00:00
Move aliases to their own file
This commit is contained in:
parent
a28e633792
commit
3d57e32014
3 changed files with 32 additions and 35 deletions
30
dot_aliases
Normal file
30
dot_aliases
Normal 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"
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ export PATH
|
||||||
# export SYSTEMD_PAGER=
|
# export SYSTEMD_PAGER=
|
||||||
|
|
||||||
# User specific aliases and functions
|
# User specific aliases and functions
|
||||||
|
source $HOME/.aliases
|
||||||
|
|
||||||
# Make the prompt pretty, just in case we're stuck in bash land
|
# 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\]] \\$ "
|
export PS1="[\[\e[32m\]\u\[\e[m\]@\[\e[33m\]\h\[\e[m\] \[\e[34m\]\W\[\e[m\]] \\$ "
|
||||||
|
|
|
@ -127,56 +127,22 @@ if [ ! -n "$SSH_CONNECTION" ]; then
|
||||||
ZLE_RPROMPT_INDENT=0
|
ZLE_RPROMPT_INDENT=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Personal aliases
|
|
||||||
alias zshconfig="$EDITOR ~/.zshrc"
|
alias zshconfig="$EDITOR ~/.zshrc"
|
||||||
alias ohmyzsh="$EDITOR ~/.oh-my-zsh"
|
source $HOME/.aliases
|
||||||
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
|
|
||||||
|
|
||||||
# Replace cat with bat
|
# Replace cat with bat
|
||||||
if [[ $(command -v bat) ]]; then
|
if [[ $(command -v bat) ]]; then
|
||||||
alias cat="bat"
|
|
||||||
export BAT_PAGER="less -RF"
|
export BAT_PAGER="less -RF"
|
||||||
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
||||||
export MANROFFOPT="-c"
|
export MANROFFOPT="-c"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Replace ls with lsd
|
|
||||||
if [[ $(command -v lsd) ]]; then
|
|
||||||
alias ls="lsd"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add notification support for long-running processes
|
# Add notification support for long-running processes
|
||||||
if [[ $(command -v ntfy) ]]; then
|
if [[ $(command -v ntfy) ]]; then
|
||||||
eval "$(ntfy shell-integration --longer-than 30)"
|
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"
|
export AUTO_NTFY_DONE_IGNORE="vim nano emacs zshconfig screen tmux ssh top htop less more most nethogs 'singularity shell' julia man"
|
||||||
fi
|
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
|
# Set the Nextflow enviroment caches
|
||||||
export NXF_HOME="$HOME/.nextflow"
|
export NXF_HOME="$HOME/.nextflow"
|
||||||
export NXF_CONDA_CACHEDIR="$NXF_HOME/conda"
|
export NXF_CONDA_CACHEDIR="$NXF_HOME/conda"
|
||||||
|
|
Loading…
Reference in a new issue