Skip to content

Instantly share code, notes, and snippets.

@czlee
Last active Jul 22, 2021
Embed
What would you like to do?
Preference files
alias gs='git status'
alias gd='git diff'
alias gdh='git diff HEAD'
alias gdw='git diff -w'
alias gka='gitk --all &'
alias grepx='grep -r -n --exclude=*.pyc --exclude=*~'
alias grepdj='grep -r -n --exclude=*.pyc --exclude=*.bak --exclude=*~ --exclude-dir=venv*'
alias li='ls --ignore=*~ --ignore=*.pyc --ignore=__pycache__'
alias notebook='BROWSER=~/jupyter-notebook-browser.sh jupyter notebook --port=8889'
venv() {
if [ -z "$1" ]; then
source venv/bin/activate
else
source /home/czlee/venvs/$1/bin/activate
fi
}
_venv_completions() {
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
COMPREPLY=($(find /home/czlee/venvs/ -mindepth 1 -maxdepth 1 -type d -name ${COMP_WORDS[1]}\* -exec basename {} \;))
}
complete -F _venv_completions venv
cdgit() {
cd /mnt/c/Users/czlee/git/$1
}
_cdgit_completions() {
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
COMPREPLY=($(find /mnt/c/Users/czlee/git/ -mindepth 1 -maxdepth 1 -type d -name ${COMP_WORDS[1]}\* -exec basename {} \;))
}
complete -F _cdgit_completions cdgit
# This just lists additions to .bashrc, not the whole file.
## 1. Uncomment the force_color_prompt=yes line
## 2. [On WSL 1]
## (a) Change the color prompt PS1 line to this:
PS1='${debian_chroot:+($debian_chroot)}\[\033[07;32m\]\u@\h\[\033[27;02;90m\]:\[\033[01;34m\]\w\[\033[00m\]\033[01;35m$(parse_git_branch)\033[00m\n\[\033[90m\]\D{%H:%M}\[\033[00m\] \$ '
## (b) Add this somewhere:
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
## 2. [On WSL 2]
## (a) Change the color prompt PS1 line to this:
PS1='${debian_chroot:+($debian_chroot)}\[\033[07;36m\]\u@\h\[\033[27;02;90m\]:\[\033[01;32m\]\w\[\033[00m\]\n\[\033[90m\]\D{%H:%M}\[\033[00m\] \$ '
## (b) Install https://github.com/magicmonty/bash-git-prompt
## (c) Add this somewhere:
# git prompt
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_START="_LAST_COMMAND_INDICATOR_ \[\033[07;36m\]\u@\h\[\033[27;02;90m\]:\[\033[01;32m\]\w\[\033[00m\]"
GIT_PROMPT_END_USER=" \n\[\033[90m\]\D{%H:%M}\[\033[00m\] $ "
GIT_PROMPT_END_ROOT=" \n\[\033[90m\]\D{%H:%M}\[\033[00m\] # "
source $HOME/.bash-git-prompt/gitprompt.sh
fi
## 3. Add this somewhere:
# For gpg-agent
GPG_TTY=$(tty)
export GPG_TTY
[core]
autocrlf = input
editor = vim
excludesfile = /mnt/c/Users/czlee/git/.gitignore
[user]
name = Chuan-Zheng Lee
email = czlee@stanford.edu
[push]
default = simple
[grep]
lineNumber = true
patternType = extended
[diff]
colorMoved = zebra
*.sublime-project
*.sublime-workspace
set number smarttab smartindent expandtab tabstop=4 shiftwidth=4
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
#!/bin/bash
# This file should be executable (chmod +x juypter-notebook-browser.sh)
file=$(echo "$1" | sed 's/file:\/\///')
url=$(grep -oP 'href="\K([^"]*localhost[^"]+)' "$file")
wslview "$url"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment