# don't need to do this # /etc/bash.bashrc # simple function to output yay or nay based on last status code # have to include it directly in PS1 so it reads the right status code echo_last_status() { if [ $? = 0 ]; then echo "👌" else echo "👎" fi # can't output a newline } # git clone git@github.com:jimeh/git-aware-prompt ~/.bash/git-aware-prompt git_branch= git_dirty= if [ -d ~/.bash/git-aware-prompt ]; then source ~/.bash/git-aware-prompt/prompt.sh fi if [ "$EUID" -ne 0 ]; then if [ "$color_prompt" = yes ]; then ps1_folder='\e[32m[\w] \e[1;34m$git_branch\e[31m$git_dirty' else ps1_folder='[w] $git_branch$git_dirty' fi fi PS1='$(echo_last_status)\n'$ps1_shelllevel$ps1_user$ps1_folder$ps1_prompt # lol alias nano='vim' # alias bashphp='docker exec -it -w "$PWD" phpfpm bash' # alias bashnode='bash ~/containers/nodejs/interactive.sh' # alias bashruby='bash ~/containers/ruby/interactive.sh' # alias bashpython='bash ~/containers/python/interactive.sh' function git { if [[ "$1" == "clone" && "$@" != *"--help"* ]]; then # I prefer to not include file permissions when cloning # unfortunately this is more involved than just the below # command git clone --config core.filemode=false "$@" curdir="$(pwd)" argsarray=($(echo $@ | tr " " "\n")) lastarg=${argsarray[-1]} penultimatearg=${argsarray[-2]} # if the penultimate arg contains @ or :// then it must be the repo url if ! case $penultimatearg in *"@"* | *"://"*) false;; esac; then newdir="$lastarg" else newdir="$(basename $lastarg .git)" fi # this original way which doesn't support args when clone'ing #if [ -z "$3" ]; then # newdir="$(basename $2 .git)" #else # newdir="$3" #fi shift 1 command git clone "$@" || return 1 cd $newdir #case $@ in # *"workgithubname"*) # command git config user.email me@work.com # echo "set user for work boss" # ;; # *"personalgithubname"*) # command git config user.email me@home.com # echo "set user for personal boss" # ;; # *) # echo "whoareyou" # ;; #esac command git config --unset core.filemode echo "removed core.filemode setting boss" cd $curdir elif [[ "$1" == "branch" && "$@" != *"--help"* && -z "$3" ]]; then shift 1 echo "switching to checkout..." command git checkout -b "$@" || command git checkout "$@" else command git "$@" fi } alias g=git complete -F _complete_alias g alias n=nautilus function docker { if [[ "$1" == "stop-and-rm" ]]; then shift 1 command docker stop "$@" command docker rm "$@" else command docker "$@" fi } alias d=docker complete -F _complete_alias d # aliases let you put things after the command if you want # i.e. get familiar with the flags but type way fewer characters # e.g. dc build --no-cache -> rebuild the images without cache # e.g. dcu -d -> dc up and detach/background it # e.g. dce app bash -> dc exec bash in the service # e.g. dcd -v -> dc down and clear volumes too alias dc=docker-compose alias dcd="docker-compose down" alias dcu="docker-compose up" #alias dce="docker-compose exec --user $(id -u):$(id -g) --env HOME=/tmp" alias dce="docker-compose exec" # persisting the changes you've made to your container # is a terrible idea and yet here it is function dcc { if [ "$#" -ne "1" ]; then echo "Precisely one argument required" return 1 fi CONTAINER=$(dc images | grep "_$1 " | awk '{print $1;}') TAGNAME=$(dc images | grep "_app " | awk '{print $2;}') TAGVERSION=$(dc images | grep "_app " | awk '{print $3;}') if [ "$CONTAINER" = "" ] || [ "$TAGNAME" = "" ] || [ "$TAGVERSION" = "" ]; then echo "Unable to figure out what to do" echo "you will need to dcu -d again if you have already run this command" return 1 fi COMMAND="docker commit $CONTAINER $TAGNAME:$TAGVERSION" echo $COMMAND eval $COMMAND } #function k8sprod { # bash --rcfile ~/.bashrc.k8s #}