Skip to content

Instantly share code, notes, and snippets.

@alexfu
Last active September 17, 2021 07:39
Show Gist options
  • Select an option

  • Save alexfu/9f152162c105f1f5e787f68f03605423 to your computer and use it in GitHub Desktop.

Select an option

Save alexfu/9f152162c105f1f5e787f68f03605423 to your computer and use it in GitHub Desktop.

Revisions

  1. alexfu revised this gist Aug 28, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git-add-interactive.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,8 @@ Add the following alias to your global `.gitconfig` file
    addi = !git add $(git status --porcelain | fzf -m | awk '{print $2}')
    ```

    _* The `!` tells git to run an external command instead of a subcommand._

    ## Step 2

    Run `git addi`. To select multiple files, use `Shift + Tab`. Press `ENTER` when done.
  2. alexfu revised this gist Aug 28, 2021. 1 changed file with 4 additions and 27 deletions.
    31 changes: 4 additions & 27 deletions git-add-interactive.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # git-addi
    # git addi

    Add git files interactively from the command line.

    @@ -10,36 +10,13 @@ Add git files interactively from the command line.

    ## Step 1

    Create a new bash script called `git-addi`...
    Add the following alias to your global `.gitconfig` file

    ```
    #!/bin/bash
    # Add files interactively
    git add $(git status --porcelain | fzf -m | awk '{print $2}')
    ```

    Make it executable...

    ```
    $ chmod +x git-addi
    [alias]
    addi = !git add $(git status --porcelain | fzf -m | awk '{print $2}')
    ```

    ## Step 2

    Move `git-addi` script to a place that is in your `$PATH`.

    For example, I have `~/.git/bin` appended to my `$PATH` variable. This is where all my git scripts live.

    ```
    export PATH=$PATH:~/.git/bin
    ```

    ```
    $ mv git-addi ~/.git/bin
    ```

    ## Step 3

    Run `git addi`. To select multiple files, use `Shift + Tab`. Press `ENTER` when done.
  3. alexfu revised this gist Aug 28, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-add-interactive.md
    Original file line number Diff line number Diff line change
    @@ -42,4 +42,4 @@ $ mv git-addi ~/.git/bin

    ## Step 3

    Execute `git addi`. To select multiple files, use `Shift + Tab`. Press `ENTER` when done.
    Run `git addi`. To select multiple files, use `Shift + Tab`. Press `ENTER` when done.
  4. alexfu revised this gist Aug 28, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-add-interactive.md
    Original file line number Diff line number Diff line change
    @@ -42,4 +42,4 @@ $ mv git-addi ~/.git/bin

    ## Step 3

    Run `git addi` and rejoice! To select multiple files, use `Shift + Tab`.
    Execute `git addi`. To select multiple files, use `Shift + Tab`. Press `ENTER` when done.
  5. alexfu revised this gist Aug 28, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-add-interactive.md
    Original file line number Diff line number Diff line change
    @@ -42,4 +42,4 @@ $ mv git-addi ~/.git/bin

    ## Step 3

    Enjoy!
    Run `git addi` and rejoice! To select multiple files, use `Shift + Tab`.
  6. alexfu revised this gist Aug 28, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git-add-interactive.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    Add git files interactively from the command line.

    [![asciicast](https://asciinema.org/a/cOqnPWQuMcbbGTqaB6qQPxLlq.svg)](https://asciinema.org/a/cOqnPWQuMcbbGTqaB6qQPxLlq)

    ## Requirements

    - [fzf](https://github.com/junegunn/fzf)
    @@ -40,4 +42,4 @@ $ mv git-addi ~/.git/bin

    ## Step 3

    Enjoy!
    Enjoy!
  7. alexfu created this gist Aug 28, 2021.
    43 changes: 43 additions & 0 deletions git-add-interactive.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    # git-addi

    Add git files interactively from the command line.

    ## Requirements

    - [fzf](https://github.com/junegunn/fzf)

    ## Step 1

    Create a new bash script called `git-addi`...

    ```
    #!/bin/bash
    # Add files interactively
    git add $(git status --porcelain | fzf -m | awk '{print $2}')
    ```

    Make it executable...

    ```
    $ chmod +x git-addi
    ```

    ## Step 2

    Move `git-addi` script to a place that is in your `$PATH`.

    For example, I have `~/.git/bin` appended to my `$PATH` variable. This is where all my git scripts live.

    ```
    export PATH=$PATH:~/.git/bin
    ```

    ```
    $ mv git-addi ~/.git/bin
    ```

    ## Step 3

    Enjoy!