# Bash # https://gnu.org/software/bash/ # https://github.com/alacritty/alacritty/issues/3624 # unset LIBGL_ALWAYS_SOFTWARE # Starship # https://starship.rs eval "$(starship init bash)" # McFly # https://github.com/cantino/mcfly eval "$(mcfly init bash)" # zoxide # https://github.com/ajeetdsouza/zoxide eval "$(zoxide init bash)" # Aliases ────────────────────────────────────────────────────────────────────── alias q=exit alias md='mkdir -p --' alias _='rm -Rf --' # Spawns a command. spawn() { nohup "$@" < /dev/null > /dev/null 2>&1 & } alias @=spawn # Run `sudo` with aliases alias sudo='sudo ' # Navigation alias ..='cd ..' alias ...='cd ../..' # NixOS # https://nixos.org alias nix-update='sudo nixos-rebuild switch' alias nix-upgrade='sudo nixos-rebuild switch --upgrade --keep-going --fallback' alias nix-gc='sudo nix-collect-garbage --delete-old' # Compiling alias nix-cargo="nix-shell --run 'cargo build --release' --packages pkg-config openssl rustup" alias nix-shards="nix-shell --run 'shards build --release --production' --packages pkg-config openssl crystal shards" # ifconfig.co # https://ifconfig.co alias ipd='curl ifconfig.co' # nginx # https://nginx.org alias nginx='sudo nginx -c /etc/nginx/nginx.conf' # procs # https://github.com/dalance/procs alias ps=procs # htop # https://htop.dev alias top=htop # rsync # https://rsync.samba.org alias rsync='rsync -azH --info=progress2 --delete' alias rsync='rsync --archive --compress --hard-links --info=progress2 --delete' # tar.xz txz() { tar caf "$1.tar.xz" "$1" } # bat # https://github.com/sharkdp/bat alias cat=bat # ripgrep # https://github.com/BurntSushi/ripgrep alias grep='rg --smart-case' # curl # https://curl.haxx.se alias curl='curl -sSL' # archiver # https://github.com/mholt/archiver alias x='arc unarchive' # tmux # https://github.com/tmux/tmux alias t=tmux alias ta='tmux attach-session' alias tl='tmux list-sessions' # Kakoune # https://kakoune.org alias k=kak alias ke=kak_set_env alias kE='kak_set_env "$(basename "$PWD")"' alias ks=kak_server alias kS='kak_server "$(basename "$PWD")"' alias ko=kak_open alias ka='kak -c "$KAKOUNE_SESSION"' alias kn='kak -n' alias kl='kak -l' # Usage: # kak_set_env [session] [client] # Sets `KAKOUNE_SESSION` and `KAKOUNE_CLIENT` environment variables. kak_set_env() { export KAKOUNE_SESSION=$1 KAKOUNE_CLIENT=$2 } # Usage: # kak_server # Only runs as server. # Sets `KAKOUNE_SESSION` and `KAKOUNE_CLIENT` environment variables. kak_server() { nohup kak -d -s "$1" < /dev/null > /dev/null 2>&1 & kak_set_env "$1" } # Usage: # kak_open [files] # Uses `KAKOUNE_SESSION` and `KAKOUNE_CLIENT` environment variables. kak_open() { { for filename do echo "edit -- %($filename)" done echo "evaluate-commands -try-client %($KAKOUNE_CLIENT) -verbatim -- edit %($1)" } | kak -p "$KAKOUNE_SESSION" } # sidetree # https://github.com/topisani/sidetree alias st='sidetree --select' alias st.=sidetree # Git # https://git-scm.com # https://cli.github.com # https://github.com/extrawurst/gitui alias g=git alias G=gitui alias gw='git add' alias gw.='gw .' alias gl='git log' alias gst='git status' # Commit alias gci='git commit' alias gcm='git commit --message' alias greword='git commit --amend' alias gpick='git commit --amend --no-edit' alias gsnapshot='date "+%F %T" | git commit --file=-' # Undo alias gu='git restore --staged' alias gD='git restore --staged --worktree' alias gD.='gD .' alias grb='git reset --hard' alias grb^='git reset --hard HEAD^' alias ggc=git-gc-all-ferocious # Navigation alias gco='git checkout -b' alias gcd='cd "$(git rev-parse --show-toplevel)"' # Web alias gv='gh repo view --web' alias gist='gh gist create --web' gc() { [ $# -lt 2 ] && suffix=.git repository=${1}${suffix} directory=$1; directory=${directory#https://}; directory=${directory%.git}; directory=~/.local/share/$directory pastel paint green --bold "Cloning '$repository' into '$directory'" git clone "$repository" "$directory" } gc2() { gc "$1" '' } gg() { gw. gD. ggc } GG() { set -- ~/.local/share/github.com/*/* ~/.local/share/gitlab.com/*/* ~/.local/share/git.sr.ht/*/* for repository do pastel paint green --bold "$repository" cd "$repository" gw. gD. ggc g pull done cd } # exa # https://the.exa.website alias l='exa --icons' alias la='exa --icons --all' alias ll='exa --icons --git --long' alias lla='exa --icons --git --long --all' alias L='exa --tree' alias La='exa --tree --all' # batch # https://github.com/taupiqueur/batch # interactive map imap() { batch -f 'iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE' -f 'tr [:upper:] [:lower:]' -f "tr -s \\'[:blank:] -" -f 'tr -d ?!,' "$@" } # auto map amap() { imap -E "$@" } # interactive mv imv() { imap -p : -M 'mkdir -vp -- "$(dirname -- "$2")" && mv -vi -- "$1" "$2"' -d 'rm -vi --' "$@" } # File manager alias o=dolphin # Web browser alias b=google-chrome-stable # mpv # https://mpv.io alias @mpv='@ mpv --no-terminal' alias m=mpv alias ms='mpv --shuffle' # yt-dlp # https://github.com/yt-dlp/yt-dlp alias y=yt-dlp # Pandoc # https://pandoc.org alias pandoc='pandoc --pdf-engine tectonic' # Ruby on Rails # https://rubyonrails.org alias r=rails alias rr='rails routes --grep' # Window managers ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ # Sway # https://swaywm.org # https://github.com/swaywm/sway/issues/3851 alias sway='WLR_NO_HARDWARE_CURSORS=1 sway' # i3 # https://i3wm.org # https://github.com/alacritty/alacritty/issues/3500 alias i3='startx /usr/bin/i3 -- -maxbigreqsize 127' # IDEs ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ # IntelliJ IDEA # https://jetbrains.com/idea/ # https://github.com/swaywm/sway/issues/595 alias idea-community='_JAVA_AWT_WM_NONREPARENTING=1 @ idea-community' # Android Studio # https://developer.android.com/studio # https://github.com/swaywm/sway/issues/595 alias android-studio='_JAVA_AWT_WM_NONREPARENTING=1 @ android-studio' # Functions ──────────────────────────────────────────────────────────────────── # Reloads bashrc. reload_bashrc() { . ~/.bash_profile } # RVM # https://rvm.io # . ~/.rvm/scripts/rvm # macOS ──────────────────────────────────────────────────────────────────────── # Sets the PATH environment variable for all services on macOS. alias set-path='sudo launchctl config user path ~/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/sbin:/usr/local/sbin:/usr/sbin:/sbin' # Erases .DS_Store and .localized files from your home folder. alias DS_Store="find ~ '(' -name '*.DS_Store' -or -name '*.localized' ')' -print -exec rm -Ri -- {} +"