diff --git a/bash/README.md b/bash/README.md index 99ba7c1..81263b3 100644 --- a/bash/README.md +++ b/bash/README.md @@ -7,3 +7,9 @@ for partial in $(ls ~/.bash.d/*.sh); do source $partial 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 +``` diff --git a/bash/colorize.sh b/bash/colorize.sh index 33706e4..68f7f5f 100644 --- a/bash/colorize.sh +++ b/bash/colorize.sh @@ -1,8 +1,2 @@ -# This file just contains some nice variable names for color codes. -C_NO='\[\033[0m\]' -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\]' +alias ls='ls --color=auto' +alias grep='grep --color=auto' diff --git a/bash/docker-machine.sh b/bash/docker-machine.sh deleted file mode 100644 index 27005bc..0000000 --- a/bash/docker-machine.sh +++ /dev/null @@ -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) -} diff --git a/bash/docker-remote.sh b/bash/docker-remote.sh new file mode 100644 index 0000000..d7ddc4a --- /dev/null +++ b/bash/docker-remote.sh @@ -0,0 +1,13 @@ +# A simple aliasing tool for performing remote docker operations over ssh +# Usage: dcontrol +# 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}" +} diff --git a/bash/gpg-up.sh b/bash/gpg-up.sh deleted file mode 100644 index 8ce79f9..0000000 --- a/bash/gpg-up.sh +++ /dev/null @@ -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 -} diff --git a/bash/misc_aliases.sh b/bash/misc_aliases.sh index 4af5ff0..ff1908a 100644 --- a/bash/misc_aliases.sh +++ b/bash/misc_aliases.sh @@ -1,7 +1,6 @@ -alias arduino-serial="busybox microcom -t 9600 /dev/ttyUSB0" -alias grep='LC_ALL="C" grep' +alias arduino_serial="busybox microcom -t 9600 /dev/ttyUSB0" alias bt='transmission-remote' 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 http="http -F --session=/tmp/session" +#alias http="http -F --session=/tmp/session" alias otp="ykman oath accounts code" diff --git a/bash/profile_snippet b/bash/profile_snippet deleted file mode 100644 index 11d6cb2..0000000 --- a/bash/profile_snippet +++ /dev/null @@ -1,3 +0,0 @@ -for partial in $(ls ~/.bash.d/*.sh); do - source $partial -done diff --git a/bash/starship.sh b/bash/starship.sh new file mode 100644 index 0000000..b6ee6e8 --- /dev/null +++ b/bash/starship.sh @@ -0,0 +1 @@ +eval "$(starship init bash)" diff --git a/bash/super_prompt.sh b/bash/super_prompt.sh deleted file mode 100644 index 4c331e9..0000000 --- a/bash/super_prompt.sh +++ /dev/null @@ -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}"