Skip to content

Instantly share code, notes, and snippets.

Last active April 16, 2022 05:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save czlee/3e1bb5159da638c61312842a7d6b7666 to your computer and use it in GitHub Desktop.
Preference files on WSL
alias gs='git status'
alias gd='git diff'
alias gdh='git diff HEAD'
alias gdw='git diff --ignore-all-space'
alias gdcw='git diff --color-words'
alias gdcc='git diff --color-words=.'
alias gl='git log --oneline -10'
alias notebook='BROWSER=~/ jupyter notebook'
alias juplab='BROWSER=~/ jupyter lab'
alias venv='source venv/bin/activate'
# Tabbycat shortcuts
bgtabbycat() {
sudo service postgresql start 13
fgtabbycat() {
export PGUSER=tabbycat PGPASSWORD=[password] PGHOST=localhost LOCAL_DEVELOPMENT=1
cd /home/czlee/tabbycat/
source venv/bin/activate
cd tabbycat
# 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
## (c) Add this somewhere:
# git prompt
if [ -f "$HOME/.bash-git-prompt/" ]; then
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/
## 3. Add this somewhere:
# For gpg-agent
export GPG_TTY
# For ssh-agent
# source:
if [ -z "$(pgrep ssh-agent)" ]; then
rm -rf /tmp/ssh-*
eval $(ssh-agent -s) > /dev/null
export SSH_AGENT_PID=$(pgrep ssh-agent)
export SSH_AUTH_SOCK=$(find /tmp/ssh-* -name agent.*)
autocrlf = input
editor = vim
excludesfile = /home/czlee/.gitignore
name = Chuan-Zheng Lee
email =
default = simple
lineNumber = true
patternType = extended
colorMoved = zebra
rebase-fix = rebase --autosquash --interactive
# courtesy of
fixup = !sh -c 'REV=$(git rev-parse $1) && git commit --fixup $@ && git rebase --interactive --autosquash $REV^' -
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()
# This file should be executable (chmod +x
file=$(echo "$1" | sed 's/file:\/\///')
url=$(grep -oP 'href="\K([^"]*localhost[^"]+)' "$file")
wslview "$url"
# This file goes in the ~/.jupyter directory
# WebIO will probably add other stuff to this file when installed
# avoid conflict with other apps that use port 8888
c.ServerApp.port = 8889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment