feat(bash): Add antidots bash config

This commit is contained in:
js0ny 2025-02-13 19:59:11 +00:00
parent f13ac93b73
commit b4030c469e
7 changed files with 180 additions and 5 deletions

134
tools/bash/bash_aliases Normal file
View file

@ -0,0 +1,134 @@
if command -v zoxide > /dev/null ; then
eval "$(zoxide init bash)"
# Relative navigation #
alias ..="z .."
alias ...="z ../.."
alias ....="z ../../.."
alias .....="z ../../../.."
alias ......="z ../../../../.."
# Use `-` to jump to the previous directory
# Oh-My-Zsh defines a similar one
-(){
z -
}
zls(){
cd $1 && ls
}
else
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
-() {
cd -
}
fi
alias ni=touch
alias cls=clear
alias ii=open
# Editors #
alias v=nvim
alias c=code
# Use neovide as gVim
alias gvi="neovide"
alias sv="sudo vim -u ~/.dotfiles/common/vim.noxdg.vimrc"
alias sn="sudo nvim -u ~/.config/nvim/init.lua"
# Dev #
alias gpp='g++ -std=c++2b' # Set the default C++ standard to C++20
alias gcc='gcc -std=c99' # Set the default C standard to C99
alias cl='clang -std=c99'
alias clpp='clang++ -std=c++2b'
alias python=python3 # Set the default Python version to Python 3
alias py=python
alias ipy=ipython
alias g=lazygit
# lsd - modern ls
if command -v lsd > /dev/null; then
alias ls='lsd'
alias l='lsd -lah'
alias ll='lsd -l'
alias la='lsd -A'
alias l.='lsd -d .*'
alias tree='lsd --tree -A'
else
alias l='ls -lah'
alias ll='ls -l'
fi
# Functions #
mkcd() {
mkdir -p $1 && cd $1
}
cdls(){
cd $1 && ls
}
tc(){
touch $1 && code $1
}
tv(){
touch $1 && nvim $1
}
mt(){
mkdir -p $(dirname $1) && touch $1
}
mtv(){
mkdir -p $(dirname $1) && touch $1 && nvim $1
}
alias update="source $DOTFILES/scripts/update.zsh"
if command -v pacman > /dev/null; then
alias pac="sudo pacman"
alias paci="sudo pacman -S"
alias pacr="sudo pacman -R"
alias pacu="sudo pacman -Syu"
alias pacl="pacman -Q"
if command -v paru > /dev/null; then
alias pacs="paru -Ss"
elif command -v yay > /dev/null; then
alias pacs="yay -Ss"
else
alias pacs="pacman -Ss"
fi
fi
if command -v apt > /dev/null; then
alias apt="sudo apt"
alias apti="sudo apt install"
alias aptr="sudo apt remove"
alias aptu="sudo apt update && sudo apt upgrade"
alias apts="apt search"
alias aptl="apt list --installed"
fi
if command -v brew > /dev/null; then
alias brewi="brew install"
alias brewr="brew uninstall"
alias brewu="brew update && brew upgrade"
alias brews="brew search"
alias brewl="brew list"
fi
# TODO: Does not work
if [ "$TERM" = "xterm-ghostty" ] || [ "$TERM" = "xterm-kitty" ]; then
alias icat="kitten icat"
elif [ "$TERM_PROGRAM" = "WezTerm" ]; then
if [ -n "$WSL_DISTRO_NAME" ]; then
alias icat="wezterm.exe imgcat"
else
alias icat="wezterm imgcat"
fi
fi

View file

@ -0,0 +1,30 @@
# If no admin rights, just
# ln -sf $DOTFILES/tools/bash/bashrc ~/.bashrc
export DOTFILES=$HOME/.dotfiles
if [ -n "$WAYLAND_DISPLAY" ]; then
alias clip="wl-copy"
alias paste="wl-paste"
elif [ -n "$DISPLAY" ]; then
alias clip="xclip"
elif [ -n "$WSL_DISTRO_NAME" ]; then
alias clip="clip.exe"
alias paste="pwsh.exe -NoProfile -Command 'Get-Clipboard'"
fi
source $DOTFILES/tools/bash/bash_aliases # For compatibility
export IPYTHONDIR="$XDG_CONFIG_HOME"/ipython
if command -v fzf > /dev/null; then
eval "$(fzf --bash)"
fi
if command -v starship > /dev/null; then
eval "$(starship init bash)"
fi
#
# bind 'set show-mode-in-prompt off'

2
tools/bash/global.bashrc Normal file
View file

@ -0,0 +1,2 @@
test -f $HOME/.config/bash/bashrc && source $HOME/.config/bash/bashrc
test -f $HOME/.bashrc && source $HOME/.bashrc

View file

@ -1,3 +1,10 @@
# Put this file in $XDG_CONFIG_HOME/bash/profile
# This file is sourced by /etc/profile.d/xdg-compat.sh
# and will source user's XDG-compliant Bash Run Commands
# If no admin rights, just
# ln -sf $DOTFILES/tools/bash/profile ~/.bash_profile
# Before antidots
if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bash_profile" ]; then
. "$HOME/.bash_profile"
@ -49,7 +56,7 @@ fi
# macOS Specific
# This syntax is POSIX standard, for portability
if [ "$(uname)" = "Darwin" ]; then
: # Do nothing
fi
# Linux Specific
@ -125,13 +132,11 @@ fi
# Ruby Gem
# Ruby Gem
if command -v gem > /dev/null; then
setopt nullglob
for dir in "$HOME/.local/share/gem/ruby/"*/bin; do
if [ -d "$dir" ]; then
export PATH="$dir:$PATH"
fi
done
unsetopt nullglob
fi
# Spacemacs
if command -v emacs > /dev/null; then