Skip to content

Instantly share code, notes, and snippets.

@uniqueg
Last active February 26, 2020 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uniqueg/da4734bae2412531d67f477f390984ad to your computer and use it in GitHub Desktop.
Save uniqueg/da4734bae2412531d67f477f390984ad to your computer and use it in GitHub Desktop.
Config options to migrate to new operating system installation

~/.bashrc

Bash prompt

To use, overwrite the default definitions of PS1 in ~/.bashrc.

Includes conda and virtualenv environments as well as the current git branch, if any. Set changeps1: false in ~/.condarc and add export VIRTUAL_ENV_DISABLE_PROMPT=1 to ~/.bashrc to to disable the default prompt modifications by conda and virtualenv, respectively.

Colored version:

PS1=''  # set to empty string; allows easy rearrangement of components
PS1+='\[\033[0;32m\]\u @ \h '  # user and host
PS1+='\[\033[0;34m\]<conda: $(basename ${CONDA_DEFAULT_ENV:-"none"})> '  # conda environment
PS1+='\[\033[0;35m\]<venv: $(basename ${VIRTUAL_ENV:-"none"})> '  # virtualenv environment
PS1+='\[\033[0;36m\]\w'  # current directory
PS1+='\[\033[0;33m\]$(__git_ps1)'  # current git branch
PS1+='\n'  # newline
PS1+='\[\033[0;32m\]└─ '  # formatting newline
PS1+='\[\033[0;32m\]\$ '  # type of prompt (user vs root)
PS1+='\[\033[0;30m\]▶  '  # formatting cursor position signal
PS1+='\[\033[0m\]'  # reset format for user input

Uncolored version:

PS1=''  # set to empty string; allows easy rearrangement of components
PS1+='\u @ \h '  # user and host
PS1+='<conda: $(basename ${CONDA_DEFAULT_ENV:-"none"})> '  # conda environment
PS1+='<venv: $(basename ${VIRTUAL_ENV:-"none"})> '  # virtualenv environment
PS1+='\w'  # current directory
PS1+='$(__git_ps1)'  # current git branch
PS1+='\n'  # newline
PS1+='└─ '  # formatting newline
PS1+='\$ '  # type of prompt (user vs root)
PS1+=''  # formatting cursor position signal

Example (no colors):

user @ host <conda: conda-env-name> <venv: virtualenv-name> ~/path/to/repo (git-branch-name)
└─ $ ▶

~/.bash_aliases

git

alias ga='git add'
alias gaa='git add -A'
alias gb='git branch'
alias gbD='git branch -D'
alias gba='git branch -a'
alias gbd='git branch -d'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gcl='git clone'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gd='git diff'
alias glg='git log --oneline'
alias gm='git merge'
alias gp='git push'
alias gpl='git pull'
alias gpo='git push origin'
alias gpu='git push --set-upstream'
alias gpuo='git push --set-upstream origin'
alias gr='git remote'
alias grm='git rm'
alias grv='git remote -v'
alias gst='git status'
alias gsts='git status -s'
alias gsu='git submodule update --init --recursive'

virtualenv

Create or activate a virtualenv Python virtual environment for the current working directory. Written with git repositories in mind.

alias vea='source ${HOME}/.venv/$(basename $PWD)/bin/activate'
alias vec='virtualenv -p $(which python3) ${HOME}/.venv/$(basename $PWD)'
alias ved='deactivate'
alias vei='venva && pip install -r requirements.txt && python setup.py develop'
alias ves='ved; vec; vei'

conda

Create or activate a conda environment for the current working directory.

alias cda='conda activate $(basename $PWD)'
alias cdc='conda create --name $(basename $PWD)'
alias cdd='conda deactivate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment