Skip to content
Ethan C edited this page May 9, 2015 · 3 revisions

Goes in ~/.bashrc, ~/.profile, or ~/.bash_profile.

# Get rid of already-merged branches
git-clean-branches() {
  git checkout master && \
    git pull --prune && \
    git branch --merged master | \
    grep -v "\* master$" | \
    xargs -n 1 git branch -d
}

# Get rid of .orig files from merge conflicts
git-clean-orig() {
    git status -su | grep -e"\.orig$" | cut -f2 -d" " | xargs rm -r
}

# Cleans all *.pyc files recursively in the current directory                 
clean-pyc() {                                                                 
  find . -name '*.pyc' -delete                                                                                                                                                            
}

# Check differences between current packages and requirements.txt
pip-diff() {
  local reqs='requirements.txt'

  if [[ ! -f $reqs ]]; then
      echo "ERROR: $reqs not found."
      return
  fi

  diff <(pip freeze) $reqs
}

# Makes pip packages match requirements.txt
pip-sync() {
  local reqs='requirements.txt'

  if [[ ! -f $reqs ]]; then
      echo "ERROR: $reqs not found."
      return
  fi

  pip freeze | grep -v -f $reqs - | xargs pip uninstall -y 2>/dev/null
  pip install -r $reqs
}

On-wiki:

Off-wiki:

     _              __
    / `\  (~._    ./  )
    \__/ __`-_\__/ ./
   _ \ \/  \   \ |_    __
 (   )  \__/ -^    \  /  \
  \_/ "  \  | o  o  | .. / __
       \\. -' ====  /  || /  \ 
         \   .  .  |---__.\__/
         /  :     /   |   |
         /   :   /     \_/
      --/ ::    (
     (  |     (  (____
   .--  .. ----**.____)
   \___/          
Clone this wiki locally