123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- # ~/.bashrc: executed by bash(1) for non-login shells.
- # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
- # for examples
- parse_git_branch() {
- git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
- }
- # If not running interactively, don't do anything
- case $- in
- *i*) ;;
- *) return;;
- esac
- # don't put duplicate lines or lines starting with space in the history.
- # See bash(1) for more options
- export HISTCONTROL=ignoreboth
- # append to the history file, don't overwrite it
- shopt -s histappend
- # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
- export HISTSIZE=
- export HISTFILESIZE=
- export HISTTIMEFORMAT="[%F %T ] "
- # If you want to be extra certain, you can force bash to write the
- # history file every prompt
- # https://superuser.com/questions/20900/bash-history-loss-when-using-histappend
- PROMPT_COMMAND="history -a"
- # check the window size after each command and, if necessary,
- # update the values of LINES and COLUMNS.
- shopt -s checkwinsize
- # If set, the pattern "**" used in a pathname expansion context will
- # match all files and zero or more directories and subdirectories.
- shopt -s globstar
- # If set, will fail if you use a '*' and there are no matches, rather than
- # passing through the wildcard.
- shopt -s failglob
- # make less more friendly for non-text input files, see lesspipe(1)
- [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
- # set variable identifying the chroot you work in (used in the prompt below)
- if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
- fi
- # set a fancy prompt (non-color, unless we know we "want" color)
- case "$TERM" in
- xterm-color) color_prompt=yes;;
- esac
- # uncomment for a colored prompt, if the terminal has the capability; turned
- # off by default to not distract the user: the focus in a terminal window
- # should be on the output of commands, not on the prompt
- force_color_prompt=yes
- if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
- fi
- if [ "$color_prompt" = yes ]; then
- #PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
- PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[33m\]$(parse_git_branch)\[\033[00m\] \$ '
- if [[ -f /etc/bash_completion.d/docker-machine-prompt.bash ]]; then
- source /etc/bash_completion.d/docker-machine-prompt.bash
- PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[33m\]$(parse_git_branch)$(__docker_machine_ps1)\[\033[00m\] \$ '
- fi
- # Also do color ls
- export CLICOLOR=true
- else
- PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
- fi
- unset color_prompt force_color_prompt
- # If this is an xterm set the title to user@host:dir
- case "$TERM" in
- xterm*|rxvt*)
- PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
- ;;
- *)
- ;;
- esac
- # enable color support of ls and also add handy aliases
- if [ -x /usr/bin/dircolors ]; then
- test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
- alias ls='ls --color=auto'
- #alias dir='dir --color=auto'
- #alias vdir='vdir --color=auto'
- alias grep='grep --color=auto'
- alias fgrep='fgrep --color=auto'
- alias egrep='egrep --color=auto'
- fi
- # some more ls aliases
- alias ll='ls -alF'
- alias la='ls -A'
- alias l='ls -CF'
- # Add an "alert" alias for long running commands. Use like so:
- # sleep 10; alert
- alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
- # Alias definitions.
- # You may want to put all your additions into a separate file like
- # ~/.bash_aliases, instead of adding them here directly.
- # See /usr/share/doc/bash-doc/examples in the bash-doc package.
- if [ -f ~/.bash_aliases ]; then
- . ~/.bash_aliases
- fi
- # enable programmable completion features (you don't need to enable
- # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
- # sources /etc/bash.bashrc).
- 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
- export GOPATH=$HOME/go
- #export GOROOT=/usr/lib/go
- #export PATH=$PATH:$GOROOT/bin
- # Add pip directory to path
- if [ -d /Users/fdamstra/Library/Python/3.10/bin ]; then
- export PATH=$PATH:/Users/fdamstra/Library/Python/3.10/bin
- fi
- # Add homebrew directories to the path
- if [ -d /opt/homebrew/bin ]; then
- export PATH=$PATH:/opt/homebrew/bin
- fi
- # Add scripts directories to the path
- if [ -d ~/scripts ]; then
- for D in ~/scripts/*; do
- export PATH=$PATH:$D
- done
- export PATH=$PATH:~/scripts
- fi
- # Add bin directories to the path
- if [ -d ~/bin ]; then
- export PATH=$PATH:~/bin
- fi
- # Add python bin directories to the path
- if [ -d ~/Library/Python/3.8/bin ]; then
- export PATH=$PATH:~/Library/Python/3.8/bin
- fi
- if [ -d ~/.chefdk/gem/ruby/2.6.0/bin ]; then
- export PATH=$PATH:~/.chefdk/gem/ruby/2.6.0/bin
- fi
- if [ -d ~/.local/bin ]; then
- export PATH=$PATH:~/.local/bin
- fi
- if [ -d ~/.gem/ruby/2.6.0/bin ]; then
- export PATH=$PATH:~/.gem/ruby/2.6.0/bin
- fi
- if [ -d ~/xdr-terraform-live/bin ]; then
- export PATH=$PATH:~/xdr-terraform-live/bin
- fi
- if [ -d ${KREW_ROOT:-$HOME/.krew}/bin ]; then
- export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
- fi
- if [ -d $HOME/.cargo ]; then
- . "$HOME/.cargo/env"
- fi
- # Add autocompletion for git
- source ~/.bash/git-completion.bash
- # Gitrob token
- [ -f ~/.git_token ] && source ~/.git_token
- # Add autocompletion for aws
- #[ -x /usr/local/bin/aws_completer ] && complete -C '/usr/local/bin/aws_completer' aws
- ## iTerm integration
- #[ -f ~/.iterm2_shell_integration.bash ] && source ~/.iterm2_shell_integration.bash
- # Additional possible paths
- [ -d /usr/local/heroku/bin ] && export PATH="/usr/local/heroku/bin:$PATH"
- [ -d $GOPATH/bin ] && export PATH="$GOPATH/bin:$PATH"
- [ -d ~/terraform ] && export PATH="~/terraform:$PATH"
- [ -d ~/esp/crosstool-NG/builds/xtensa-esp32-elf ] && export PATH="~/esp/crosstool-NG/builds/xtensa-esp32-elf:$PATH"
- # We want SSH keys to have passwords, so load the ssh agent
- SSH_ENV="$HOME/.ssh/environment"
- function start_agent {
- echo "Initialising new SSH agent..."
- /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
- echo succeeded
- chmod 600 "${SSH_ENV}"
- . "${SSH_ENV}" > /dev/null
- if [[ "$OSTYPE" == "darwin21" ]]; then
- /usr/bin/ssh-add --apple-load-keychain
- else
- /usr/bin/ssh-add
- fi
- }
- # Source SSH settings, if applicable
- if [ -f "${SSH_ENV}" ]; then
- . "${SSH_ENV}" > /dev/null
- #ps ${SSH_AGENT_PID} doesn't work under cywgin
- ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
- start_agent;
- }
- else
- start_agent;
- fi
- # Make less allow colors
- export LESS="-R"
- [ -f /opt/homebrew/bin/thefuck ] && eval $(/opt/homebrew/bin/thefuck --alias)
- # These are legacy
- #export ANSIBLE_INVENTORY=~/ansible/ansible_hosts
- #export ANSIBLE_HOST_KEY_CHECKING=False
- # Make sure vundle is installed
- [ -f ~/.vim/bundle/Vundle.vim/autoload/vundle.vim ] || git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- [[ $(type -P fortune) ]] && [[ $(type -P cowsay) ]] && [[ $(type -P lolcat) ]] && fortune | cowsay | lolcat
- # tabtab source for serverless package
- # uninstall by removing these lines or running `tabtab uninstall serverless`
- [ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash ] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash
- # tabtab source for sls package
- # uninstall by removing these lines or running `tabtab uninstall sls`
- [ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash ] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash
- [ -f ~/MyEnvironment/iterm2_shell_integration.bash ] && . ~/MyEnvironment/iterm2_shell_integration.bash
- [ -f "`which chef`" ] && eval "$(chef shell-init bash)"
- # Python venv?
- if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
- if [ -f ~/awsinfo/scripts/awsinfo.bash ]; then
- alias awsinfo=~/awsinfo/scripts/awsinfo.bash
- fi
- alias python='python3'
- # WHen were passwords changed
- #echo; echo Password Last Changed:; u=$(dscl . list /Users | egrep -v '^_|daemon|nobody'); for i in $u; do printf \\n$i\\t; currentUser=$i;t=$(dscl . read /Users/"$currentUser" | grep -A1 passwordLastSetTime | grep real | awk -F'real>|</real' '{print $2}'); date -j -f %s "$t" 2> /dev/null; done
- if [[ "$(uname -s)" == "Darwin" ]]; then
- # Print password expirations:
- echo
- echo -n Password Expiration:
- u=$(dscl . list /Users | egrep -v '^_|daemon|nobody|root')
- for i in $u; do
- printf \\n$i\\t;
- currentUser=$i;
- t=$(dscl . read /Users/"$currentUser" | grep -A1 passwordLastSetTime | grep real | awk -F'real>|</real' '{print $2}');
- t=$(echo "$t" | cut -f1 -d".");
- t=$(expr $t + 5184000);
- echo -n $(date -j -f "%s" "$t" 2> /dev/null);
- done;
- echo
- fi
- #if [[ -x `which bw` ]]; then
- # export LANG=en_CA.UTF-8;export LOCALE=en_CA.UTF-8; `which bw` slab
- #fi
- if [[ -x `which microk8s` ]]; then
- alias kubectl='microk8s kubectl'
- fi
- # May be incompatible with tf14+
- export TF_PLUGIN_CACHE_DIR=~/.terraform.d/plugin-cache
- [[ -d "$TF_PLUGIN_CACHE_DIR" ]] || mkdir -p $TF_PLUGIN_CACHE_DIR
- # Better colors
- export LSCOLORS="gxfxcxdxbxegedabagacad"
- # Disable bell for tab completion
- #bind 'set bell-style none'
- export EDITOR=vim
- # Import crowdstrike-specific settings
- [[ -f ~/.bashrc.crowdstrike ]] && source ~/.bashrc.crowdstrike
- alias activate='source env/bin/activate'
- echo ""
- echo "Reminder: Use command-shift-s to save your window arrangement, command-shift-r to restore."
- echo ""
|