Skip to content

Instantly share code, notes, and snippets.

@robCrawford
Last active October 18, 2022 09:40
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 robCrawford/d68bc4188bd1b3ad502c6739519b9dba to your computer and use it in GitHub Desktop.
Save robCrawford/d68bc4188bd1b3ad502c6739519b9dba to your computer and use it in GitHub Desktop.
Open modified and new files in working directory using VSCode
#!/usr/bin/env zsh
# Opens modified and new files in working directory using VSCode
wip() {
cd $(git rev-parse --show-toplevel) &&
code $(git diff $1 $2 --diff-filter=d --name-only) $(git status -s | grep '??' | grep -v '/$' | cut -c 4-) &&
cd -;
}
# Opens modified and new files in the previous commit using VSCode
# Can provide a hash for changes in that commit e.g. `wiprev 982ab5a`
wiprev() {
commit="${1:-head}"
wip "$commit^" "$commit"
}
# Opens modified and new files in the current branch using VSCode
wipbr() {
cd $(git rev-parse --show-toplevel) &&
code $(git diff master...$1 --name-only --diff-filter=d) $(git status -s | grep '??' | grep -v '/$' | cut -c 4-) &&
cd -;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment