Update bash scripts.

This commit is contained in:
Anna Rose Wiggins 2025-07-30 12:22:46 -04:00
parent d97fea0e94
commit 8e69cd62c3
9 changed files with 24 additions and 71 deletions

View file

@ -7,3 +7,9 @@ for partial in $(ls ~/.bash.d/*.sh); do
source $partial source $partial
done done
``` ```
You may also want to ensure you have this near the top of your bashrc, to avoid executing all of these scripts for every non-interactive bash script:
```
[[ $- != *i* ]] && return
```

View file

@ -1,8 +1,2 @@
# This file just contains some nice variable names for color codes. alias ls='ls --color=auto'
C_NO='\[\033[0m\]' alias grep='grep --color=auto'
C_RED='\[\033[1;31m\]'
C_GREEN='\[\033[1;32m\]'
C_YELLOW='\[\033[1;33m\]'
C_BLUE='\[\033[1;34m\]'
C_MAGENTA='\[\033[1;35m\]'
C_CYAN='\[\033[1;36m\]'

View file

@ -1,10 +0,0 @@
# A simple wrapper for docker-machine.
function dcontrol() {
if [ $1 = "off" ]; then
eval $(docker-machine env -u)
return
fi
eval $(docker-machine env $1)
}

13
bash/docker-remote.sh Normal file
View file

@ -0,0 +1,13 @@
# A simple aliasing tool for performing remote docker operations over ssh
# Usage: dcontrol <somehost.com>
# Assumes you have key-based root login
function dcontrol() {
if [ -z $1 ] || [ $1 == "off" ]; then
unalias docker 2> /dev/null
unset DOCKER_HOST
return
fi
export DOCKER_HOST=$1
alias docker="docker -H ssh://root@${DOCKER_HOST}"
}

View file

@ -1,14 +0,0 @@
# This function ensures gpg commands will work properly, in the current shell. I have found it needful on
# OS X when using a smartcard and gpg-agent for ssh auth, in particular.
function gpg-up() {
while [[ $(ps axu | grep gpg-agent | grep -v grep | wc -l | tr -d ' ') -ne '0' ]]; do
pkill gpg-agent
sleep 1
done
gpg-agent --daemon
. ~/.gpg-agent-info
GPG_TTY=$(tty)
export GPG_TTY GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID
}

View file

@ -1,7 +1,6 @@
alias arduino-serial="busybox microcom -t 9600 /dev/ttyUSB0" alias arduino_serial="busybox microcom -t 9600 /dev/ttyUSB0"
alias grep='LC_ALL="C" grep'
alias bt='transmission-remote' alias bt='transmission-remote'
alias dockviz="docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz" alias dockviz="docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz"
alias timestamp="date -u +'%Y%m%d%H%M%S'" alias timestamp="date -u +'%Y%m%d%H%M%S'"
alias http="http -F --session=/tmp/session" #alias http="http -F --session=/tmp/session"
alias otp="ykman oath accounts code" alias otp="ykman oath accounts code"

View file

@ -1,3 +0,0 @@
for partial in $(ls ~/.bash.d/*.sh); do
source $partial
done

1
bash/starship.sh Normal file
View file

@ -0,0 +1 @@
eval "$(starship init bash)"

View file

@ -1,33 +0,0 @@
# Produces a nice, colorful 2-line prompt of the form:
# [username@hostname:current_directory] (git_repo|branch)
# $
#
# You can add the output of arbitrary env vars with something like this:
# ${C_RED}\$(echo -n \$ENV_VAR_NAME)${C_NO}
src_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source $src_dir/colorize.sh
function sp_git {
# Get the current branch name
local git_branch=$(git branch 2>/dev/null | grep "*" | cut -d ' ' -f 2) || ""
# If we're in a git repo, add the repo (i.e. top-level directory) name, and parens
if [ "$git_branch" != "" ]; then
local git_repo=$(git rev-parse --show-toplevel)
git_repo=${git_repo//*\/}
echo "(${git_repo}|${git_branch})"
fi
}
function sp_path {
local git_dir=$(git rev-parse --show-toplevel 2>/dev/null)
if [ "$git_dir" != "" ]; then
local path=${PWD//$git_dir/\!}
else
local path=${PWD//$HOME/\~}
fi
echo $path
}
export PS1="[${C_YELLOW}\u${C_NO}@${C_BLUE}${HOSTNAME}${C_NO}:${C_GREEN}\$(sp_path)${C_NO}] ${C_MAGENTA}\$(sp_git)${C_NO} ${C_RED}\$(echo -n \$DOCKER_MACHINE_NAME)${C_NO} \n${C_RED}\$ ${C_NO}"