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