aboutsummaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
authorclaw0ry <me@claw0ry.net>2024-12-11 13:58:21 +0100
committerclaw0ry <me@claw0ry.net>2024-12-11 13:58:21 +0100
commitb56b0d3ca316395a903ed1c7a040bda0ae321c36 (patch)
treeda8a7e975f0f426095350403dc3b39f4fd1ad5dd /.bashrc
fresh start
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc123
1 files changed, 123 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc
new file mode 100644
index 0000000..e66f8d2
--- /dev/null
+++ b/.bashrc
@@ -0,0 +1,123 @@
+#!/bin/bash
+
+# quit if not running interactively
+[[ $- != *i* ]] && return
+
+# --- LOCAL UTILITY FUNCTIONS
+_have() { type "$1" &>/dev/null; }
+_source_if() { [[ -r "$1" ]] && source "$1"; }
+
+# --- ENVIRONMENT
+export CLICOLOR=1
+export EDITOR=vi
+export GIT_EDITOR=vi
+export VISUAL=vi
+export LC_ALL=en_US.UTF-8
+export LANG=en_US.UTF-8
+export LC_CTYPE=en_US.UTF-8
+export TERM="xterm-256color"
+export FZF_DEFAULT_COMMAND='ag --hidden -g ""'
+export GOPROXY=direct
+export GOPATH="$HOME/.local/go"
+export FUNCTIONS_CORE_TOOLS_TELEMETRY_OUTPUT=1
+
+# --- PATHS
+export PATH="$HOME/.local/go/bin:$PATH"
+export PATH="$HOME/.local/bin:$PATH"
+export PATH="$HOME/.local/scripts:$PATH"
+export PATH="$HOME/bin:$PATH"
+export PATH="/usr/local/sbin:$PATH"
+export XDG_CACHE_HOME="$HOME/.cache"
+export XDG_CONFIG_HOME="$HOME/.config"
+export XDG_DATA_HOME="$HOME/.local/share"
+
+# --- BASH SHELL OPTIONS
+shopt -s histappend
+shopt -s checkwinsize
+
+# --- HISTORY
+export HISTSIZE=10000
+export HISTFILESIZE=10000
+export HISTCONTROL=ignoreboth
+
+# --- PROMPT
+__ps1() {
+ local branch_color="\e[1;35m"
+ local branch_prompt
+ local branch_prompt_clr
+ local git_branch=$(git branch --show-current 2>/dev/null)
+
+ local sign_prompt='\$'
+ local sign_prompt_clr='\e[00m\$'
+
+ [[ $git_branch == master || $git_branch == main ]] && branch_color="\e[31m"
+ [[ -n "$git_branch" ]] && branch_prompt_clr="$branch_color($git_branch)"
+ [[ -n "$git_branch" ]] && branch_prompt="($git_branch)"
+
+ [[ $EUID == 0 ]] && sign_prompt='#'
+ [[ $EUID == 0 ]] && sign_prompt_clr='\e[31m#\e[00m'
+
+ case "$TERM" in
+ xterm-color|*-256color)
+ PS1="\e[01;32m\u@\h\e[00m:\e[01;34m\W $branch_prompt_clr$sign_prompt_clr ";;
+ *)
+ PS1="\u@\h:\W $branch_prompt$sign_prompt ";;
+ esac
+}
+
+if [ -x "$(command -v oh-my-posh)" ]; then
+ eval "$(oh-my-posh init bash --config $XDG_CONFIG_HOME/oh-my-posh/config.yml)"
+else
+ PROMPT_COMMAND="__ps1"
+fi
+
+# --- ALIASES
+alias rm='rm -i'
+alias mv='mv -i'
+alias cp='cp -i'
+alias ls="ls -h --color=auto"
+alias ll="ls -laH --color=auto"
+alias gcm="git commit -m"
+alias gsa="git status -uall"
+alias gap="git add -p"
+alias gpf="git pull && git fetch --prune"
+alias gitl="git log -n 5 --graph --decorate --oneline"
+alias tree="tree -a -I 'node_modules|.git'"
+
+_have vim && alias vi=vim && EDITOR=vim && GIT_EDITOR=vim
+_have nvim && alias vi=nvim && EDITOR=nvim && GIT_EDITOR=nvim
+
+# --- KEYBINDINGS
+bind -x '"\C-f": tmux-sessionizer'
+
+# --- COMPLETIONS
+_source_if "/etc/bash_completion"
+_source_if "$HOME/.fzf.bash"
+_source_if "$HOME/.git-completion.bash"
+
+# --- PERSONALIZED CONFIGURATIONS
+_source_if "$HOME/.bash_personal"
+_source_if "$HOME/.bash_work"
+
+# --- LAZY LOAD NVM (node version manager)
+lazy_load_nvm() {
+ unset -f npm node nvm
+ export NVM_DIR="$HOME/.nvm"
+ _source_if "$NVM_DIR/nvm.sh"
+ _source_if "$NVM_DIR/bash_completion"
+}
+
+npm() {
+ lazy_load_nvm
+ npm $@
+}
+
+node() {
+ lazy_load_nvm
+ node $@
+}
+
+nvm() {
+ lazy_load_nvm
+ node $@
+}