Last active
February 22, 2019 15:56
-
-
Save borisschapira/b41ea13e6922d0b4792df934372ff892 to your computer and use it in GitHub Desktop.
Open code for workspace if available, file if configured, new workspace if nothing else
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A function to replace the `code` command | |
# | |
# With args: does what's intended. | |
# ``` | |
# > code ~/.bash_history | |
# ``` | |
# | |
# With no args, opens the first workspace it founds | |
# in the current folder, or a new workspace based | |
# on the current folder if none exists. | |
# ``` | |
# > code | |
# ``` | |
function code-ws() { | |
if [ ! $# -eq 0 ]; then | |
code "$@" | |
else | |
files=$(find . -maxdepth 1 -type f -name "*.code-workspace" | wc -l) | |
if [ $files -eq 0 ]; then | |
code -n . | |
else | |
code *.code-workspace | |
fi | |
fi | |
} | |
alias code=code-ws |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment