Skip to content

Instantly share code, notes, and snippets.

@borisschapira
Last active February 22, 2019 15:56
Show Gist options
  • Select an option

  • Save borisschapira/b41ea13e6922d0b4792df934372ff892 to your computer and use it in GitHub Desktop.

Select an option

Save borisschapira/b41ea13e6922d0b4792df934372ff892 to your computer and use it in GitHub Desktop.

Revisions

  1. borisschapira revised this gist Feb 22, 2019. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions .profile
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,16 @@
    # A function to replace the `code` command
    #
    # Open a file
    # > code code ~/.bash_history
    # With args: does what's intended.
    # ```
    # > code ~/.bash_history
    # ```
    #
    # Open the first workspace it founds, or a new
    # workspace on the current folder
    # 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
  2. borisschapira revised this gist Feb 22, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .profile
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@

    function code-ws() {
    if [ ! $# -eq 0 ]; then
    code $1;
    code "$@"
    else
    files=$(find . -maxdepth 1 -type f -name "*.code-workspace" | wc -l)
    if [ $files -eq 0 ]; then
  3. borisschapira revised this gist Feb 22, 2019. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion .profile
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,12 @@
    # A function to replace the `code` command
    #
    # Open a file
    # > code code ~/.bash_history
    #
    # Open the first workspace it founds, or a new
    # workspace on the current folder
    # > code

    function code-ws() {
    if [ ! $# -eq 0 ]; then
    code $1;
    @@ -6,7 +15,7 @@ function code-ws() {
    if [ $files -eq 0 ]; then
    code -n .
    else
    code *.code-workspace
    code *.code-workspace
    fi
    fi
    }
  4. borisschapira created this gist Feb 22, 2019.
    13 changes: 13 additions & 0 deletions .profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function code-ws() {
    if [ ! $# -eq 0 ]; then
    code $1;
    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