mirror of
https://github.com/jessebot/dot_files.git
synced 2025-10-01 01:48:43 +00:00
organize all the bashrc stuff into a config dir
This commit is contained in:
parent
b2c17557bb
commit
f984a3eb40
11 changed files with 323 additions and 294 deletions
|
@ -1,8 +1,40 @@
|
|||
# just to make sure we always source .bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
# this is the iterm2 shell integration stuff, making it use XDG_CONFIG_HOME
|
||||
source "${HOME}/.config/iterm2/shell_integration.sh"
|
||||
source "$HOME/.config/bash/iterm2_integration.sh"
|
||||
|
||||
# iterm2 specific commands and functions
|
||||
export PATH=$PATH:$HOME/.local/bin/iterm2
|
||||
|
||||
# this is for macs without apple silicon, e.g. before M1
|
||||
export PATH=$PATH:$HOME/Library/Python/3.11/bin
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ macOS PATH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
if [[ $(uname) == *"Darwin"* ]]; then
|
||||
# don't warn me that BASH is deprecated, becasuse it is already upgraded
|
||||
export BASH_SILENCE_DEPRECATION_WARNING=1
|
||||
# bash completion on macOS
|
||||
if [ -f "/usr/local/etc/profile.d/bash_completion.sh" ]; then
|
||||
# sources bash completion
|
||||
. "/usr/local/etc/profile.d/bash_completion.sh"
|
||||
fi
|
||||
|
||||
pip_path="lib/python3.11/site-packages"
|
||||
|
||||
# check if this apple silicon
|
||||
if [ $(uname -a | grep arm > /dev/null ; echo $?) -eq 0 ]; then
|
||||
# On M1/M2: brew default installs here
|
||||
export PATH=/opt/homebrew/bin:$PATH
|
||||
pip_packages="/opt/homebrew/$pip_path"
|
||||
else
|
||||
# For older macs before the M1, pre-2020
|
||||
pip_packages="/usr/local/$pip_path"
|
||||
fi
|
||||
|
||||
# Load GNU sed, called gsed, instead of MacOS's POSIX sed
|
||||
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
|
||||
|
||||
# Always use GNU sed
|
||||
alias sed='gsed'
|
||||
fi
|
||||
|
||||
# just to make sure we always source .bashrc
|
||||
source ~/.bashrc
|
||||
|
|
309
.bashrc
309
.bashrc
|
@ -1,7 +1,4 @@
|
|||
# @jessebot's personal .bashrc (and .bash_profile) #
|
||||
##############################################################################
|
||||
|
||||
|
||||
# @jessebot's personal .bashrc
|
||||
# -------------------------------------------------------------------------- #
|
||||
# General #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
@ -16,7 +13,7 @@ esac
|
|||
# I hate bells a lot
|
||||
set bell-style none
|
||||
|
||||
# python version is subject to change
|
||||
# python version is subject to change, but really important
|
||||
export PYTHON_VERSION="3.11"
|
||||
|
||||
# this just makes howdoi use colors
|
||||
|
@ -25,299 +22,34 @@ export HOWDOI_COLORIZE=1
|
|||
# makes gpg prompt for passphrase in the terminal for git commit -S
|
||||
export GPG_TTY=$(tty)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# History
|
||||
# --------------------------------------------------------------------------
|
||||
# source all the pathing exports
|
||||
. ~/.config/bash/path.sh
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
# history settings are in this file
|
||||
. $XDG_CONFIG_HOME/bash/history.sh
|
||||
|
||||
# name of the history file to create and log to
|
||||
HISTFILE="$HOME/.local/state/bash/.history"
|
||||
# everything to do with things like less and editors is in here
|
||||
. $XDG_CONFIG_HOME/bash/text_editing.sh
|
||||
|
||||
# don't put duplicate lines or lines starting with space in the history.
|
||||
HISTCONTROL=ignoreboth
|
||||
# aliases are all confined to this file
|
||||
. $XDG_CONFIG_HOME/bash/alias.sh
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=10000
|
||||
HISTFILESIZE=20000
|
||||
# k8s aliases and configuration
|
||||
. $XDG_CONFIG_HOME/bash/k8s.sh
|
||||
|
||||
# for setting time stamps on history
|
||||
HISTTIMEFORMAT="%d/%m/%y %T "
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------- #
|
||||
# Text Editor
|
||||
# Default, in order of preference (subject to availability): nvim, vim, vi
|
||||
# ------------------------------------------------------------------------- #
|
||||
|
||||
# Default EDITOR is nvim
|
||||
if [ -n "$(which nvim)" ]; then
|
||||
export EDITOR=nvim
|
||||
# if nvim is not available, set EDITOR to vim
|
||||
else
|
||||
export EDITOR=vim
|
||||
fi
|
||||
|
||||
# always use nvim (or vim) instead of vi
|
||||
alias vi=$EDITOR
|
||||
|
||||
# make all colors work by default
|
||||
export TERM=xterm-256color
|
||||
|
||||
# -- This is for making some basic resizing working with various cli tools --
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------- #
|
||||
# TEXT VIEWING #
|
||||
# ------------------------------------------------------------------------- #
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# colors for less when displaying man pages
|
||||
export LESS_TERMCAP_mb=$'\e[1;32m'
|
||||
export LESS_TERMCAP_md=$'\e[1;32m'
|
||||
export LESS_TERMCAP_me=$'\e[0m'
|
||||
export LESS_TERMCAP_se=$'\e[0m'
|
||||
export LESS_TERMCAP_so=$'\e[01;33m'
|
||||
export LESS_TERMCAP_ue=$'\e[0m'
|
||||
export LESS_TERMCAP_us=$'\e[1;4;35m'
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cat ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
||||
# TODO: Write those docs with links to both apps (rich, and bat)
|
||||
# Function to use the best syntax highlighting app for the job
|
||||
function dog {
|
||||
# if file has more lines than legnth of the terminal use app with pager
|
||||
too_long=false
|
||||
if [ $(wc -l $1 | awk '{print $1}') -gt $(tput lines) ]; then
|
||||
too_long=true
|
||||
fi
|
||||
|
||||
# if this is a markdown or csv file, ALWAYS use rich to print the data
|
||||
if [[ "$1" == *".md" ]] || [[ "$1" == *".csv" ]]; then
|
||||
if $too_long; then
|
||||
# pager allows moving with j for down, k for up, and :q for quit
|
||||
rich --pager $1
|
||||
else
|
||||
rich $1
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
# use batcat - sytnax highlighting + git support and pager
|
||||
bat $1
|
||||
fi
|
||||
}
|
||||
|
||||
alias raw='env cat'
|
||||
alias cat='dog'
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Pathing #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GENERAL PATH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
# golang requires this
|
||||
GOROOT=$HOME
|
||||
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Linux PATH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
if [[ $(uname) == *"Linux"* ]]; then
|
||||
|
||||
# iptables on debian is here
|
||||
export PATH=$PATH:/usr/sbin:/usr/share
|
||||
|
||||
# snap package manager installs commands here
|
||||
export PATH=$PATH:/snap/bin
|
||||
|
||||
# HomeBrew on Linux needs all of this to work
|
||||
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
|
||||
export HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar
|
||||
export HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew
|
||||
export MANPATH=$MANPATH:/home/linuxbrew/.linuxbrew/share/man
|
||||
export INFOPATH=$INFOPATH:/home/linuxbrew/.linuxbrew/share/info
|
||||
export PATH=$PATH:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin
|
||||
# pip packages installed via linuxbrew will be here
|
||||
pip_packages="/home/linuxbrew/.linuxbrew/lib/python$PYTHON_VERSION/site-packages"
|
||||
fi
|
||||
|
||||
# python default install location when you do: pip$PYTHON_VERSION install --user package
|
||||
export PATH=$PATH:$HOME/.local/bin
|
||||
# this is for macs without apple silicon, e.g. before M1
|
||||
export PATH=$PATH:/usr/local/bin:$HOME/Library/Python/$PYTHON_VERSION/bin
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ macOS PATH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
if [[ $(uname) == *"Darwin"* ]]; then
|
||||
# don't warn me that BASH is deprecated, becasuse it is already upgraded
|
||||
export BASH_SILENCE_DEPRECATION_WARNING=1
|
||||
# bash completion on macOS
|
||||
if [ -f "/usr/local/etc/profile.d/bash_completion.sh" ]; then
|
||||
# sources bash completion
|
||||
. "/usr/local/etc/profile.d/bash_completion.sh"
|
||||
fi
|
||||
|
||||
pip_path="lib/python$PYTHON_VERSION/site-packages"
|
||||
|
||||
# check if this apple silicon
|
||||
if [ $(uname -a | grep arm > /dev/null ; echo $?) -eq 0 ]; then
|
||||
# On M1/M2: brew default installs here
|
||||
export PATH=/opt/homebrew/bin:$PATH
|
||||
pip_packages="/opt/homebrew/$pip_path"
|
||||
else
|
||||
# For older macs before the M1, pre-2020
|
||||
pip_packages="/usr/local/$pip_path"
|
||||
fi
|
||||
|
||||
# Load GNU sed, called gsed, instead of MacOS's POSIX sed
|
||||
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
|
||||
# Always use GNU sed
|
||||
alias sed='gsed'
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# ALIASES #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Typos <3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
alias pign='ping'
|
||||
alias gtop='gotop'
|
||||
# can never spell clear
|
||||
alias celar='clear'
|
||||
alias clar='clear'
|
||||
# clear, but in dutch
|
||||
alias leegmaken='clear'
|
||||
alias gti='git'
|
||||
alias gtt='git'
|
||||
# can't spell tree
|
||||
alias ter='tree'
|
||||
alias tre='tree'
|
||||
alias tere='tree'
|
||||
|
||||
# can't spell python
|
||||
alias pthyon="python$PYTHON_VERSION"
|
||||
alias ptyhon="python$PYTHON_VERSION"
|
||||
alias pythong="python$PYTHON_VERSION"
|
||||
# alias because versions lower than python$PYTHON_VERSION still in some places
|
||||
alias python="python$PYTHON_VERSION"
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ General ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
||||
# colordiff - diff, but with colors for accessibility
|
||||
alias diff='colordiff -uw'
|
||||
|
||||
# we love a good tracer t
|
||||
alias tracert='traceroute'
|
||||
|
||||
# whoami, whereami, whoareyou?
|
||||
alias whereami='hostname'
|
||||
alias whoareyou='echo "Your friend :)"'
|
||||
|
||||
# scrncpy installs adb for you, but it's awkward to use, so we just alias it
|
||||
alias adb='scrcpy.adb'
|
||||
|
||||
# I never remember what the img2sixel command is called
|
||||
alias sixel='img2sixel'
|
||||
|
||||
# quick to do
|
||||
alias todo="$EDITOR ~/todo.md"
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ls ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
# lsd instead of ls for colors/icons
|
||||
alias ls='lsd -a'
|
||||
# lsd and list long, human readable file sizes, show hidden files
|
||||
alias ll='lsd -hal'
|
||||
# sort by most recent and reversed, so the most recent file is the last
|
||||
# helpful for directories with lots of files
|
||||
alias lt='lsd -atr'
|
||||
# same as above, but long
|
||||
alias llt='lsd -haltr'
|
||||
# lsd already has a fancier tree command with icons
|
||||
alias tree='lsd --tree --depth=2'
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ grep ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
# always use colors
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias grpe='grep'
|
||||
alias gerp='grep'
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ git ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
alias gc='git commit -m'
|
||||
alias gs='git status'
|
||||
# check all directories below current directory for their git status
|
||||
alias gsa='ls -1 -A | xargs -I % sh -c "if [ -d % ]; then toilet -f smblock % | lolcat ; cd %; git status --short; cd - > /dev/null; echo ''; fi"'
|
||||
alias gd='git diff'
|
||||
alias ga='git add .'
|
||||
alias gph='git push && git push --tags'
|
||||
alias gpl='git pull'
|
||||
# glab is gitlab's cli, but I always type gl by accident
|
||||
alias gl='glab'
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# COMPLETION #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# ~~~~~~~~~~~~~~~~ enable programmable completion features ~~~~~~~~~~~~~~~~~ #
|
||||
if ! shopt -oq posix; then
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
elif [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nvm for node.js ~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
# This loads nvm
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
# This loads nvm bash_completion
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Terraform ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
complete -C /usr/local/bin/terraform terraform
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# -------------------------- CUSTOM FUNCTIONS ----------------------------- #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ base64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
||||
#
|
||||
function b64 {
|
||||
echo -n $1 | base64
|
||||
}
|
||||
|
||||
# set decode to be
|
||||
function decode {
|
||||
echo -n $1 | base64 --decode
|
||||
}
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ag (search repos) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
function agr {
|
||||
if [ $2 = "y"]; then
|
||||
for $repo in $(ls -1 $REPOS); do
|
||||
cd $REPOS/$repo && git pull
|
||||
done
|
||||
fi
|
||||
ag $1 $REPOS
|
||||
}
|
||||
# load additional bash completion for different commands
|
||||
. $XDG_CONFIG_HOME/bash/completion.sh
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Other Load on start #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# include external ~/.config/bash/$application if it exists
|
||||
# example: if there's a .bashrc_k8s, source that as well
|
||||
for bash_file in `ls -1 $HOME/.config/bash`; do
|
||||
# This loads nvm
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
|
||||
|
||||
# include external rc files in ~/.config/bash/personal if they exist
|
||||
for bash_file in `ls -1 $XDG_CONFIG_HOME/bash/personal`; do
|
||||
. $bash_file
|
||||
done
|
||||
|
||||
|
@ -332,7 +64,6 @@ fi
|
|||
# -------------------------------------------------------------------------- #
|
||||
# PERSONAL MOTD #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# run neofetch, a system facts cli script, immediately when we login anywhere
|
||||
echo ""
|
||||
neofetch
|
||||
|
|
107
.config/bash/alias.sh
Normal file
107
.config/bash/alias.sh
Normal file
|
@ -0,0 +1,107 @@
|
|||
# -------------------------------------------------------------------------- #
|
||||
# SHELL ALIASES #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Typos <3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
alias pign='ping'
|
||||
alias gtop='gotop'
|
||||
# can never spell clear
|
||||
alias celar='clear'
|
||||
alias clar='clear'
|
||||
# clear, but in dutch
|
||||
alias leegmaken='clear'
|
||||
# can't spell tree
|
||||
alias ter='tree'
|
||||
alias tre='tree'
|
||||
alias tere='tree'
|
||||
|
||||
# can't spell python
|
||||
alias pthyon="python$PYTHON_VERSION"
|
||||
alias ptyhon="python$PYTHON_VERSION"
|
||||
alias pythong="python$PYTHON_VERSION"
|
||||
# alias because versions lower than python$PYTHON_VERSION still in some places
|
||||
alias python="python$PYTHON_VERSION"
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ General ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
||||
# colordiff - diff, but with colors for accessibility
|
||||
alias diff='colordiff -uw'
|
||||
|
||||
# we love a good tracer t
|
||||
alias tracert='traceroute'
|
||||
|
||||
# whoami, whereami, whoareyou?
|
||||
alias whereami='hostname'
|
||||
alias whoareyou='echo "Your friend :)"'
|
||||
|
||||
# scrncpy installs adb for you, but it's awkward to use, so we just alias it
|
||||
alias adb='scrcpy.adb'
|
||||
|
||||
# I never remember what the img2sixel command is called
|
||||
alias sixel='img2sixel'
|
||||
|
||||
# quick to do
|
||||
alias todo="$EDITOR ~/todo.md"
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ls ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
# lsd instead of ls for colors/icons
|
||||
alias ls='lsd -a'
|
||||
# lsd and list long, human readable file sizes, show hidden files
|
||||
alias ll='lsd -hal'
|
||||
# sort by most recent and reversed, so the most recent file is the last
|
||||
# helpful for directories with lots of files
|
||||
alias lt='lsd -atr'
|
||||
# same as above, but long
|
||||
alias llt='lsd -haltr'
|
||||
# lsd already has a fancier tree command with icons
|
||||
alias tree='lsd --tree --depth=2'
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ grep ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
# always use colors
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias grpe='grep'
|
||||
alias gerp='grep'
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ git ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
||||
alias gc='git commit -m'
|
||||
alias gs='git status'
|
||||
# check all directories below current directory for their git status
|
||||
alias gsa='ls -1 -A | xargs -I % sh -c "if [ -d % ]; then toilet -f smblock % | lolcat ; cd %; git status --short; cd - > /dev/null; echo ''; fi"'
|
||||
alias gd='git diff'
|
||||
alias ga='git add .'
|
||||
alias gph='git push && git push --tags'
|
||||
alias gpl='git pull'
|
||||
# can't spell git
|
||||
alias gti='git'
|
||||
alias gtt='git'
|
||||
|
||||
# glab is gitlab's cli, but I always type gl by accident
|
||||
alias gl='glab'
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# -------------------------- CUSTOM FUNCTIONS ----------------------------- #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ag (search repos) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
function agr {
|
||||
if [ $2 = "y"]; then
|
||||
for $repo in $(ls -1 $REPOS); do
|
||||
cd $REPOS/$repo && git pull
|
||||
done
|
||||
fi
|
||||
ag $1 $REPOS
|
||||
}
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ base64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
||||
function b64 {
|
||||
echo -n $1 | base64
|
||||
}
|
||||
|
||||
# set decode to be base64 decode
|
||||
function decode {
|
||||
echo -n $1 | base64 --decode
|
||||
}
|
18
.config/bash/completion.sh
Normal file
18
.config/bash/completion.sh
Normal file
|
@ -0,0 +1,18 @@
|
|||
# -------------------------------------------------------------------------- #
|
||||
# TAB COMPLETION #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# ~~~~~~~~~~~~~~~~ enable programmable completion features ~~~~~~~~~~~~~~~~~ #
|
||||
if ! shopt -oq posix; then
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
elif [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Terraform ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
complete -C /usr/local/bin/terraform terraform
|
||||
|
||||
# This loads nvm (for node.js) bash_completion
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
19
.config/bash/history.sh
Normal file
19
.config/bash/history.sh
Normal file
|
@ -0,0 +1,19 @@
|
|||
# --------------------------------------------------------------------------
|
||||
# History
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# name of the history file to create and log to
|
||||
HISTFILE="$HOME/.local/state/bash/.history"
|
||||
|
||||
# don't put duplicate lines or lines starting with space in the history.
|
||||
HISTCONTROL=ignoreboth
|
||||
|
||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||
HISTSIZE=10000
|
||||
HISTFILESIZE=20000
|
||||
|
||||
# for setting time stamps on history
|
||||
HISTTIMEFORMAT="%d/%m/%y %T "
|
45
.config/bash/path.sh
Normal file
45
.config/bash/path.sh
Normal file
|
@ -0,0 +1,45 @@
|
|||
# --------------------------------------------------------------------------
|
||||
# Pathing
|
||||
# Adhereing as closely as possible to XDG Base Directory Spec:
|
||||
# https://wiki.archlinux.org/title/XDG_Base_Directory
|
||||
# --------------------------------------------------------------------------
|
||||
export XDG_CONFIG_HOME="$HOME/.config"
|
||||
export XDG_CACHE_HOME="$HOME/.cache"
|
||||
export XDG_DATA_HOME="$HOME/.local/share"
|
||||
export XDG_STATE_HOME="$HOME/.local/state"
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ LinuxBrew PATH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
if [[ $(uname) == *"Linux"* ]]; then
|
||||
|
||||
# iptables on debian is here
|
||||
export PATH=$PATH:/usr/sbin:/usr/share
|
||||
|
||||
# snap package manager installs commands here
|
||||
export PATH=$PATH:/snap/bin
|
||||
|
||||
# HomeBrew on Linux needs all of this to work
|
||||
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
|
||||
export HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar
|
||||
export HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew
|
||||
export MANPATH=$MANPATH:/home/linuxbrew/.linuxbrew/share/man
|
||||
export INFOPATH=$INFOPATH:/home/linuxbrew/.linuxbrew/share/info
|
||||
export PATH=$PATH:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin
|
||||
# pip packages installed via linuxbrew will be here
|
||||
pip_packages="/home/linuxbrew/.linuxbrew/lib/python$PYTHON_VERSION/site-packages"
|
||||
fi
|
||||
|
||||
# python default install location when you do: pip$PYTHON_VERSION install --user package
|
||||
export PATH=$PATH:$HOME/.local/bin:/usr/local/bin
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~ nvm/npm for javascript stuff ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
export NVM_DIR="$XDG_DATA_HOME"/nvm
|
||||
# also for js stuff
|
||||
export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc
|
||||
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ golang ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
GOROOT=$HOME
|
||||
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
|
||||
|
||||
# Make grade use XDG
|
||||
export GRADLE_USER_HOME=$XDG_DATA_HOME/gradle
|
68
.config/bash/text_editing.sh
Normal file
68
.config/bash/text_editing.sh
Normal file
|
@ -0,0 +1,68 @@
|
|||
# ------------------------------------------------------------------------- #
|
||||
# Text Editor
|
||||
# Default, in order of preference (subject to availability): nvim, vim, vi
|
||||
# ------------------------------------------------------------------------- #
|
||||
|
||||
# Default EDITOR is nvim
|
||||
if [ -n "$(which nvim)" ]; then
|
||||
export EDITOR=nvim
|
||||
# if nvim is not available, set EDITOR to vim
|
||||
else
|
||||
export EDITOR=vim
|
||||
fi
|
||||
|
||||
# always use nvim (or vim) instead of vi
|
||||
alias vi=$EDITOR
|
||||
|
||||
# make all colors work by default
|
||||
export TERM=xterm-256color
|
||||
|
||||
# -- This is for making some basic resizing working with various cli tools --
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------- #
|
||||
# TEXT VIEWING #
|
||||
# ------------------------------------------------------------------------- #
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
# colors for less when displaying man pages
|
||||
export LESS_TERMCAP_mb=$'\e[1;32m'
|
||||
export LESS_TERMCAP_md=$'\e[1;32m'
|
||||
export LESS_TERMCAP_me=$'\e[0m'
|
||||
export LESS_TERMCAP_se=$'\e[0m'
|
||||
export LESS_TERMCAP_so=$'\e[01;33m'
|
||||
export LESS_TERMCAP_ue=$'\e[0m'
|
||||
export LESS_TERMCAP_us=$'\e[1;4;35m'
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cat ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||
|
||||
# TODO: Write those docs with links to both apps (rich, and bat)
|
||||
# Function to use the best syntax highlighting app for the job
|
||||
function dog {
|
||||
# if file has more lines than legnth of the terminal use app with pager
|
||||
too_long=false
|
||||
if [ $(wc -l $1 | awk '{print $1}') -gt $(tput lines) ]; then
|
||||
too_long=true
|
||||
fi
|
||||
|
||||
# if this is a markdown or csv file, ALWAYS use rich to print the data
|
||||
if [[ "$1" == *".md" ]] || [[ "$1" == *".csv" ]]; then
|
||||
if $too_long; then
|
||||
# pager allows moving with j for down, k for up, and :q for quit
|
||||
rich --pager $1
|
||||
else
|
||||
rich $1
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
# use batcat - sytnax highlighting + git support and pager
|
||||
bat $1
|
||||
fi
|
||||
}
|
||||
|
||||
alias raw='env cat'
|
||||
alias cat='dog'
|
3
.config/npm/npmrc
Normal file
3
.config/npm/npmrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
prefix=${XDG_DATA_HOME}/npm
|
||||
cache=${XDG_CACHE_HOME}/npm
|
||||
init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js
|
8
.zshrc
8
.zshrc
|
@ -10,7 +10,13 @@ export RPROMPT='${vcs_info_msg_0_} %(1j.%B%j%b.)%(2L.%U%L%u.)'
|
|||
export HOSTNAME=`hostname`
|
||||
export CORRECT_IGNORE="_*"
|
||||
|
||||
# Set a more permissive history
|
||||
# make zsh cache to the XDG location
|
||||
mkdir -p ~/.cache/zsh/zcompdump-$ZSH_VERSION
|
||||
compinit -d ~/.cache/zsh/zcompdump-$ZSH_VERSION
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# HISTORY
|
||||
# -----------------------------------------------------------------
|
||||
export HISTSIZE=2000
|
||||
export HISTFILE=~/.local/state/zsh/history
|
||||
export SAVEHIST=2000
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue