1 # ~/.bashrc: executed by bash(1) for non-login shells.
2 cat /dev/null > ~/.bash_history
4 # If not running interactively, don't do anything
10 # don't put duplicate lines in the history. See bash(1) for more options
11 # don't overwrite GNU Midnight Commander's setting of `ignorespace'.
12 export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
13 # ... or force ignoredups and ignorespace
14 export HISTCONTROL=ignoreboth
16 # append to the history file, don't overwrite it
19 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
21 # check the window size after each command and, if necessary,
22 # update the values of LINES and COLUMNS.
25 # make less more friendly for non-text input files, see lesspipe(1)
26 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
31 # set variable identifying the chroot you work in (used in the prompt below)
32 if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
33 debian_chroot=$(cat /etc/debian_chroot)
36 # enable color support of ls and also add handy aliases
37 if [ -x /usr/bin/dircolors ]; then
39 alias ls='ls --color=auto'
40 alias dir='dir --color=auto'
41 alias vdir='vdir --color=auto'
43 alias grep='grep --color=auto'
44 alias fgrep='fgrep --color=auto'
45 alias egrep='egrep --color=auto'
48 alias emacs='emacs -nw'
49 alias serve='python -m SimpleHTTPServer 8080'
55 # Enable programmable completion features (you don't need to enable
56 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
57 # sources /etc/bash.bashrc).
58 if [ -f /etc/bash_completion ]; then
59 . /etc/bash_completion
62 # Add the ~/bin directory to the path. This allows you to install simple
63 # binaries by simply moving them into ~/bin.
64 if [ -d $HOME/bin ]; then
65 PATH="$HOME/bin:$PATH"
69 # Put $HOME/.cabal/bin on the path. Installing cabal doesn't
70 # automatically put installed packages on the path.
71 if [ -d $HOME/.cabal/bin ]; then
72 PATH="$HOME/.cabal/bin:$PATH"
76 # Put /usr/local/bin (where homebrew installs stuff) before /usr/bin on the
77 # path. This means that if a program exists at both locations, calls to that
78 # program will use the homebrew version rather than the system version.
79 PATH="/usr/local/bin:$PATH"
82 # Run a machine-specific bashrc (if it exists).
83 if [ -f $HOME/.bashrc_local ]; then
84 source $HOME/.bashrc_local
87 # Automatically open screen.
88 # The if statement prevents it from recursing (since screen opens bash).
89 if [ $TERM != screen ] && [ $TERM != screen.xterm-256color ] ; then
93 # Gets a directory named .env or .venv if it exists in the currend directory or any of its parents
95 if [ -d "$1/.env" ] ; then
98 if [ -d "$1/.venv" ] ; then
101 if [ -d "$1/.." ] ; then
108 get_absolute_path() {
109 python3 -c "import os; print(os.path.realpath('$1'))"
113 # Load a virtualenv environment if it exists in a file named .env
114 env_folder=$(get_env $(pwd))
116 if [ -d "$env_folder" ] ; then
117 if [[ $VIRTUAL_ENV != $(get_absolute_path $env_folder) ]] ; then
118 echo "Activating env '$env_folder'"
119 source "$env_folder/bin/activate"
122 if [ -d "$VIRTUAL_ENV" ] ; then
128 # Call on_prompt() every time the command prompt executes
129 PROMPT_COMMAND=on_prompt
134 # pip should only run if there is a virtualenv currently activated
135 export PIP_REQUIRE_VIRTUALENV=true
137 export NVM_DIR="$HOME/.nvm"
138 [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
139 [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion