From 4bacf7f45edbe9fc0a499b3cae526de9f40828eb Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Wed, 23 Oct 2024 00:19:57 -0400 Subject: [PATCH] Update bashrc to moduler --- .bashrc | 96 ++++++++++++------------------------------ .bashrc.d/archlinux | 2 + .bashrc.d/colors | 15 +++++++ .bashrc.d/commands | 31 ++++++++++++++ .bashrc.d/editor | 8 ++++ .bashrc.d/history | 11 +++++ .bashrc.d/protontricks | 5 +++ .bashrc.d/tuning | 8 ++++ .bashrc.d/zzextensions | 16 +++++++ 9 files changed, 122 insertions(+), 70 deletions(-) create mode 100644 .bashrc.d/archlinux create mode 100644 .bashrc.d/colors create mode 100644 .bashrc.d/commands create mode 100644 .bashrc.d/editor create mode 100644 .bashrc.d/history create mode 100644 .bashrc.d/protontricks create mode 100644 .bashrc.d/tuning create mode 100644 .bashrc.d/zzextensions diff --git a/.bashrc b/.bashrc index 99640fc..3642b5a 100644 --- a/.bashrc +++ b/.bashrc @@ -8,35 +8,6 @@ case $- in *) return;; esac -# don't put duplicate lines or lines starting with space in the history. -# See bash(1) for more options -HISTCONTROL=ignoreboth - -# append to the history file, don't overwrite it -shopt -s histappend - -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# If set, the pattern "**" used in a pathname expansion context will -# match all files and zero or more directories and subdirectories. -#shopt -s globstar - -# make less more friendly for non-text input files, see lesspipe(1) -if [ ! -f /etc/gentoo-release ]; then - [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" -fi - -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color|*-256color) color_prompt=yes;; @@ -59,45 +30,21 @@ if [ -n "$force_color_prompt" ]; then fi if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' + PS1='\u@\h:\w\$ ' fi unset color_prompt force_color_prompt # If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + PS1="\[\e]0;\u@\h: \w\a\]$PS1" ;; *) ;; esac -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# colored GCC warnings and errors -export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Add an "alert" alias for long running commands. Use like so: -# sleep 10; alert -alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' - # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. @@ -110,6 +57,14 @@ test -r ~/.shell-env && . ~/.shell-env test -r ~/.shell-aliases && . ~/.shell-aliases test -r ~/.shell-common && . ~/.shell-common +# User specific environment +if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then + export PATH="$HOME/.local/bin:$HOME/bin:$PATH" +fi + +# Uncomment the following line if you don't like systemctl's auto-paging feature: +# export SYSTEMD_PAGER= + # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). @@ -121,22 +76,23 @@ if ! shopt -oq posix; then fi fi -test -r ~/.bashrc_local && ~/.bashrc.local - - -eval "$(direnv hook bash)" -eval "$(starship init bash)" - -if [[ -d "$HOME/.tmuxifier/bin" ]]; then - export PATH="$PATH:$HOME/.tmuxifier/bin" - eval "$(tmuxifier init -)" -elif [[ -d "$HOME/.tmux/plugins/tmuxifier/bin" ]]; then - export PATH="$PATH:$HOME/.tmux/plugins/tmuxifier/bin" - eval "$(tmuxifier init -)" +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc fi -alias protontricks='flatpak run com.github.Matoking.protontricks' -alias protontricks-launch='flatpak run --command=protontricks-launch com.github.Matoking.protontricks' +# User specific aliases and functions +if [ -d ~/.bashrc.d ]; then + for rc in ~/.bashrc.d/*; do + if [ -f "$rc" ]; then + . "$rc" + fi + done +fi +unset rc + +test -r ~/.bashrc_local && ~/.bashrc.local + if [[ -n "$KONSOLE_VERSION" ]]; then if [[ "$KONSOLE_DBUS_SESSION" == "/Sessions/1" ]]; then diff --git a/.bashrc.d/archlinux b/.bashrc.d/archlinux new file mode 100644 index 0000000..808ed27 --- /dev/null +++ b/.bashrc.d/archlinux @@ -0,0 +1,2 @@ +# Pacman Aliases +#alias pkgq="pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'" diff --git a/.bashrc.d/colors b/.bashrc.d/colors new file mode 100644 index 0000000..8b11ba5 --- /dev/null +++ b/.bashrc.d/colors @@ -0,0 +1,15 @@ +# enable color support of ls and also add handy aliases +if [[ -x /usr/bin/dircolors ]]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + #alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + diff --git a/.bashrc.d/commands b/.bashrc.d/commands new file mode 100644 index 0000000..4fd6005 --- /dev/null +++ b/.bashrc.d/commands @@ -0,0 +1,31 @@ +# vim: set ft=sh sw=2 et : +alias dos2unix='sed "s/%//"' + +alias tmux='tmux -2' + +if command -v tmuxinator >/dev/null 2>&1; then + alias mux='tmuxinator' +fi + +alias ls='ls --color=auto' +alias ll='\ls -l' +alias lla='\ls -la' +alias lt='\ls --color=auto -lhFart' +if command -v lsd >/dev/null 2>&1; then + alias ls='lsd' + alias ll='lsd -l' + alias lla='lsd -la' +fi + +alias grep='grep --color=auto' + +if [[ -n "$TMUX" ]]; then + alias fzf='fzf-tmux' +fi + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +if [[ "$OSTYPE" == "linux-gnu" ]]; then + alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' +fi + diff --git a/.bashrc.d/editor b/.bashrc.d/editor new file mode 100644 index 0000000..615c159 --- /dev/null +++ b/.bashrc.d/editor @@ -0,0 +1,8 @@ +if command -v vim >/dev/null 2>&1; then + alias vi=vim +fi +if command -v nvim >/dev/null 2>&1; then + alias vim=nvim + alias vi=nvim +fi + diff --git a/.bashrc.d/history b/.bashrc.d/history new file mode 100644 index 0000000..bded804 --- /dev/null +++ b/.bashrc.d/history @@ -0,0 +1,11 @@ +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + diff --git a/.bashrc.d/protontricks b/.bashrc.d/protontricks new file mode 100644 index 0000000..942d561 --- /dev/null +++ b/.bashrc.d/protontricks @@ -0,0 +1,5 @@ +if [[ "$OSTYPE" == "linux-gnu" ]]; then + alias protontricks='flatpak run com.github.Matoking.protontricks' + alias protontricks-launch='flatpak run --command=protontricks-launch com.github.Matoking.protontricks' +fi + diff --git a/.bashrc.d/tuning b/.bashrc.d/tuning new file mode 100644 index 0000000..b35dd01 --- /dev/null +++ b/.bashrc.d/tuning @@ -0,0 +1,8 @@ +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + diff --git a/.bashrc.d/zzextensions b/.bashrc.d/zzextensions new file mode 100644 index 0000000..5aafb45 --- /dev/null +++ b/.bashrc.d/zzextensions @@ -0,0 +1,16 @@ +if command -v direnv >/dev/null 2>&1; then + eval "$(direnv hook bash)" +fi + +if command -v starship >/dev/null 2>&1; then + eval "$(starship init bash)" +fi + +if [[ -d "$HOME/.tmuxifier/bin" ]]; then + export PATH="$PATH:$HOME/.tmuxifier/bin" + eval "$(tmuxifier init -)" +elif [[ -d "$HOME/.tmux/plugins/tmuxifier/bin" ]]; then + export PATH="$PATH:$HOME/.tmux/plugins/tmuxifier/bin" + eval "$(tmuxifier init -)" +fi +