General cleanup, and put everything through shellcheck
This commit is contained in:
		
							parent
							
								
									54ebcdd409
								
							
						
					
					
						commit
						e9165f2949
					
				
							
								
								
									
										10
									
								
								.bashrc
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								.bashrc
									
									
									
									
									
								
							@ -21,7 +21,11 @@ shopt -s autocd
 | 
			
		||||
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
 | 
			
		||||
 | 
			
		||||
# Prefer vim, but if it's not installed, nano will do
 | 
			
		||||
[[ -s /usr/bin/vim ]] && export EDITOR=vim || export EDITOR=nano
 | 
			
		||||
if [[ -s /usr/bin/vim ]]; then
 | 
			
		||||
       	export EDITOR=vim
 | 
			
		||||
else
 | 
			
		||||
	export EDITOR=nano
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Enable pkgfile to automatically search for packages if pkgfile is installed
 | 
			
		||||
[[ -s /usr/share/doc/pkgfile/command-not-found.bash ]] && source /usr/share/doc/pkgfile/command-not-found.bash
 | 
			
		||||
@ -31,9 +35,11 @@ export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43
 | 
			
		||||
 | 
			
		||||
# Source all *.sh files in ~/.bashrc.d/
 | 
			
		||||
# This way all my useful little utilities are easier to reference and fix
 | 
			
		||||
for f in ~/.bashrc.d/*.sh; do source $f; done
 | 
			
		||||
# shellcheck source=/dev/null
 | 
			
		||||
for f in ~/.bashrc.d/*.sh; do source "$f"; done
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Source a local bashrc if it exists. This gives the ability to insert untracked
 | 
			
		||||
# modifications to this .bashrc
 | 
			
		||||
# shellcheck source=/dev/null
 | 
			
		||||
[[ -s ~/.local.bashrc ]] && source ~/.local.bashrc
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,13 @@
 | 
			
		||||
countdown() {
 | 
			
		||||
	if [ -z "$1" ]; then
 | 
			
		||||
		printf "
 | 
			
		||||
countdown: Count down while printing progress on the terminal
 | 
			
		||||
 | 
			
		||||
Usage: countdown <seconds>
 | 
			
		||||
"
 | 
			
		||||
	fi
 | 
			
		||||
	local secs="$1"
 | 
			
		||||
	while [ $secs -gt 0 ]; do
 | 
			
		||||
	while [ "$secs" -gt 0 ]; do
 | 
			
		||||
		echo -ne "$secs\033[0K\r"
 | 
			
		||||
		sleep 1
 | 
			
		||||
		: $((secs--))
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,5 @@
 | 
			
		||||
fontfind() { if [[ -z $1 || ${#1} -gt 1 ]]; then
 | 
			
		||||
fontfind() { 
 | 
			
		||||
	if [[ -z $1 || ${#1} -gt 1 ]]; then
 | 
			
		||||
		printf "E: only one character accepted"
 | 
			
		||||
	fi
 | 
			
		||||
	local glyph=$1
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,6 @@
 | 
			
		||||
# shellcheck disable=SC2120
 | 
			
		||||
# shellcheck disable=SC2119
 | 
			
		||||
 | 
			
		||||
# Print Dell Service Tag
 | 
			
		||||
getdst() {
 | 
			
		||||
	if [[ "$1" = "-l" ]]; then
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,5 @@
 | 
			
		||||
# shellcheck disable=SC2016
 | 
			
		||||
 | 
			
		||||
promptsetup() {
 | 
			
		||||
	# Color definitions for prompt
 | 
			
		||||
	local fg_brightred='\[$(tput setaf 9)\]'
 | 
			
		||||
@ -16,7 +18,7 @@ promptsetup() {
 | 
			
		||||
	[ -n "$SSH_CLIENT" ] && hostname="${fg_brightred}\h${reset}"
 | 
			
		||||
 | 
			
		||||
	# If in a python venv, add venv name in green.
 | 
			
		||||
	[ -n "$VIRTUAL_ENV" ] && mixin=" ${fg_green}$(basename $VIRTUAL_ENV)${reset}"
 | 
			
		||||
	[ -n "$VIRTUAL_ENV" ] && mixin=" ${fg_green}$(basename "$VIRTUAL_ENV")${reset}"
 | 
			
		||||
 | 
			
		||||
	# If in a vcsh repo env, add repo name in magenta.
 | 
			
		||||
	[ -n "$VCSH_REPO_NAME" ] && mixin=" ${fg_magenta}$VCSH_REPO_NAME${reset}"
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,14 @@
 | 
			
		||||
# Screenshot utils
 | 
			
		||||
shot() {
 | 
			
		||||
	# Usage: shot XY
 | 
			
		||||
	local destdir="$HOME/Pictures/screenshots"
 | 
			
		||||
	local fname="shot-$(date +%F-%T).png"
 | 
			
		||||
	local fname
 | 
			
		||||
	local pb="fb"
 | 
			
		||||
	local paste msgt msgd opts
 | 
			
		||||
	fname="shot-$(date +%F-%T).png"
 | 
			
		||||
 | 
			
		||||
	if [ -z "$1" ]; then
 | 
			
		||||
		printf "Usage: shot XY
 | 
			
		||||
		printf "
 | 
			
		||||
Usage: shot XY
 | 
			
		||||
X: Target
 | 
			
		||||
Y: Destination
 | 
			
		||||
 | 
			
		||||
@ -38,7 +39,7 @@ p	Upload to a pastebin (defined in function)
 | 
			
		||||
			msgt="mouse selection"
 | 
			
		||||
			;;
 | 
			
		||||
 | 
			
		||||
		*)	printf "Unknown target: %s\n" "${1:0:1}"
 | 
			
		||||
		*)	printf "Invalid target: %s\n" "${1:0:1}"
 | 
			
		||||
			return
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
@ -52,7 +53,7 @@ p	Upload to a pastebin (defined in function)
 | 
			
		||||
			msgd="pastebin"
 | 
			
		||||
			paste=1;;
 | 
			
		||||
 | 
			
		||||
		*)	printf "Unknown destination: %s\n" "${1:1:1}"
 | 
			
		||||
		*)	printf "Invalid destination: %s\n" "${1:1:1}"
 | 
			
		||||
			return
 | 
			
		||||
			;;
 | 
			
		||||
	esac
 | 
			
		||||
@ -60,11 +61,13 @@ p	Upload to a pastebin (defined in function)
 | 
			
		||||
	# Make sure destination directory will exist
 | 
			
		||||
	[[ ! -d "$destdir" ]] && mkdir -p "$destdir"
 | 
			
		||||
	local fpath="${destdir}/${fname}"
 | 
			
		||||
 | 
			
		||||
	# If target is active window, give a 5 second countdown before running maim
 | 
			
		||||
	[[ "$msgt" = "active window" ]] && countdown 5
 | 
			
		||||
 | 
			
		||||
	maim $opts "$fpath"
 | 
			
		||||
	maim "$opts" "$fpath"
 | 
			
		||||
	printf "Captured %s -> %s\n" "$msgt" "$msgd"
 | 
			
		||||
 | 
			
		||||
	# If destination is a pastebin, do the needful
 | 
			
		||||
	[[ "$paste" ]] && $pb "$fpath"
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,10 @@
 | 
			
		||||
# shellcheck disable=SC1090
 | 
			
		||||
 | 
			
		||||
vactivate() {
 | 
			
		||||
	local path=~/.venv/$1
 | 
			
		||||
 | 
			
		||||
	if [[ ! -d $path ]]; then
 | 
			
		||||
		python -m venv --prompt "venv: $1" --system-site-packages $path
 | 
			
		||||
		python -m venv --prompt "venv: $1" --system-site-packages "$path"
 | 
			
		||||
	fi
 | 
			
		||||
	source $path/bin/activate; bash; deactivate
 | 
			
		||||
	source "$path"/bin/activate; bash; deactivate
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user