dots/.bashrc

128 lines
3.1 KiB
Bash
Raw Normal View History

2020-04-07 22:24:30 +02:00
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
2023-02-26 23:38:43 +01:00
source /etc/os-release
2022-10-25 20:54:01 +02:00
# Aliases {{{
2020-10-30 16:49:22 +01:00
# Load aliases dynamically
2023-05-21 19:35:20 +02:00
[ -f "$HOME/.bash_aliases/all" ] && source "$HOME/.bash_aliases/all"
[ -f "$HOME/.bash_aliases/$HOSTNAME" ] && source "$HOME/.bash_aliases/$HOSTNAME"
2023-08-02 16:42:46 +02:00
[ -f "$HOME/.bash_aliases/private" ] && source "$HOME/.bash_aliases/private"
# }}}
2023-08-02 17:06:28 +02:00
2023-08-02 17:09:16 +02:00
# Dynamic configuration {{{
2023-08-02 17:06:28 +02:00
[ -f "$HOME/.bashrc.d/$HOSTNAME" ] && source "$HOME/.bashrc.d/$HOSTNAME"
2023-08-02 17:09:16 +02:00
[ -f "$HOME/.bashrc.d/private" ] && source "$HOME/.bashrc.d/private"
2023-08-02 17:06:28 +02:00
# }}}
2022-10-25 20:54:01 +02:00
# Prompt {{{
2020-05-07 02:10:20 +02:00
get_branch_name() {
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|| git rev-parse --short HEAD 2>/dev/null \
|| echo 'some branch'
}
get_git_info() {
git rev-parse --is-inside-work-tree &>/dev/null || return
2021-03-28 10:39:14 +02:00
echo -e "$(get_branch_name)"
2020-05-07 02:10:20 +02:00
}
2020-04-07 22:24:30 +02:00
2022-10-25 20:54:33 +02:00
PS1="\u \w ❭\[$(tput sgr0)\] "
2022-10-25 20:54:01 +02:00
# Ellipsis when deep in directory
export PROMPT_DIRTRIM=2
2022-10-25 20:54:33 +02:00
export PS1
2022-10-25 20:54:01 +02:00
# }}}
# Path {{{
# Add ~/.bin to PATH
export PATH=~/.bin:$PATH
# }}}
# History {{{
2021-12-31 12:44:28 +01:00
export HISTCONTROL=ignoreboth:erasedups
2020-08-18 18:20:58 +02:00
export HISTSIZE=500000
2022-05-11 01:15:26 +02:00
# Omit `clear, ls...`; commands prepended with space
2021-12-31 12:44:28 +01:00
export HISTIGNORE="clear:l: *"
2022-10-25 20:54:01 +02:00
# }}}
2020-04-07 22:24:30 +02:00
2022-10-25 20:54:01 +02:00
# Man pages {{{
2023-03-12 13:15:43 +01:00
# See `:h :Man` in NeoVim
export MANWIDTH=999
# export MANPAGER='nvim +Man!'
2022-10-25 20:54:01 +02:00
# }}}
# Editor {{{
# Set vim as default editor
export EDITOR=nvim
2023-08-02 16:58:55 +02:00
export SUDO_EDITOR=nvim
2022-10-25 20:54:01 +02:00
# }}}
2020-12-10 19:40:55 +01:00
2020-10-30 16:49:22 +01:00
# Nvm
2021-08-31 14:28:09 +02:00
export PATH=~/.nvm/versions/node/v14.16.0/bin:$PATH
export NVM_DIR="$HOME/.nvm"
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh" --no-use
2022-10-25 20:54:01 +02:00
# X11 {{{
2021-08-31 14:28:30 +02:00
export XDG_SESSION_TYPE=X11
export XDG_CONFIG_HOME=$HOME/.config
2023-05-15 13:45:55 +02:00
export XDG_DATA_HOME=$HOME/.local/share
2022-10-25 20:54:01 +02:00
# }}}
2021-08-31 14:28:30 +02:00
2022-10-25 20:54:01 +02:00
# Nix package manager {{{
2022-10-25 20:56:54 +02:00
# Add ~/.nix-profile/bin to PATH
export PATH=~/.nix-profile/bin:$PATH
2022-10-25 20:54:01 +02:00
# }}}
2022-10-25 20:54:01 +02:00
# FZF {{{
2022-10-25 20:56:01 +02:00
# Check if fzf is installed
if [ -f "/usr/bin/fzf" ]; then
# Fuzzy finder setup
export FZF_COMPLETION_TRIGGER='**'
export FZF_DEFAULT_COMMAND='ag --hidden --skip-vcs-ignores -t -g ""'
export FZF_DEFAULT_OPTS="
--pointer='❭'
--height 10%
--color=fg:-1,bg:-1"
export FZF_CTRL_T_COMMAND="${FZF_DEFAULT_COMMAND}"
export FZF_CTRL_T_OPTS="--preview='bat {} | head -500'"
2023-02-26 23:59:09 +01:00
if [[ $ID == "raspbian" ]]; then
source /usr/share/doc/fzf/examples/completion.bash
source /usr/share/doc/fzf/examples/key-bindings.bash
elif [[ $ID == "arch" ]]; then
source /usr/share/fzf/completion.bash
source /usr/share/fzf/key-bindings.bash
fi
2023-03-12 13:17:54 +01:00
_fzf_setup_completion path vim zathura xournalpp nvim mpv
2022-10-25 20:56:01 +02:00
else
echo "fzf not installed"
fi
2022-10-25 20:54:01 +02:00
# }}}
# Node {{{
2022-10-25 20:57:14 +02:00
# Move nvm folder away from home directory
export NVM_DIR="${XDG_CONFIG_HOME}/nvm"
# Pretty much what is in `/usr/share/nvm/init-nvm.sh` but we add the `--no-use`
# flag to `nvm.sh` to make it lazy
source /usr/share/nvm/nvm.sh --no-use
source /usr/share/nvm/bash_completion
source /usr/share/nvm/install-nvm-exec
2022-10-25 20:54:01 +02:00
# }}}
# Jupyter {{{
export JUPYTERLAB_DIR=$HOME/.local/share/jupyter/lab
2022-10-25 20:54:01 +02:00
# }}}
2023-03-12 13:15:43 +01:00
# Conda {{{
[ -f /opt/miniconda3/etc/profile.d/conda.sh ] && source /opt/miniconda3/etc/profile.d/conda.sh
# }}}
2023-05-01 15:34:27 +02:00
2023-08-02 17:12:37 +02:00
# Mamba/micromamba {{{
complete -o default -F _umamba_bash_completions mm
# }}}
2023-05-01 15:34:27 +02:00
# Zettelkasten {{{
export ZK_PATH="$HOME/.zk"