1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-03 07:37:47 +00:00
Commit graph

50 commits

Author SHA1 Message Date
Cattle_Horse
4f7d9a626a
feat(git): Added complementary support for the git config subcommands (#1117) 2025-05-10 07:37:51 -05:00
Jan Klass
1930c7b47f
Drop draft note (#1088)
This comment was a WIP draft note.
The separate `git show` command call is not necessary because
`get-all-git-local-refs` through `for-each-ref` already includes the
commit title. So the comment can be dropped without further
consideration / is already resolved.
2025-04-19 08:42:48 -05:00
Jan Klass
3ad271f838
Improve git completions (#1087)
* Fix previous logic assuming single remote name `origin`
* Fix wrong Local vs Remote branch name descriptions
* Fix git branch output with multiple branches per line breaking
auto-completions
* Fix current branch not showing up in git checkout branch completions
* Fix remote branches not showing up when local branch with upstream
exists despite them being different refs
* Show more contextual information in completion descriptions
* Use consistent sorting between command completions; Local branches
before remote branches before files before commits, with sorting from
git kept intact

Change implementation to a more encapsulated and type-specific approach:

* Use for-each-ref instead of git branch with manual current branch
query and current and HEAD ref removal
* Separate local and remote branch logic for good case separation
  * Use separate for-each-ref calls for early case separation
* Decorate local and remote branch information in their respective cases
instead of content-conditional
* Decorate with 'Branch, Local|Remote, Commit Sha1 Subject, upstream
[head|behind x]
* Use new consistent description format '{Type}' | '{Type}, Commit
{Sha1} Subject | '{Type}, {Subtype}, {Commit Sha1+Subject}, {upstream
name + track}
* Dissolves some spread out logic, dropping commands
get-all-git-branches and extract-remote-branches-nonlocal-short and
extract-mergable-sources

Influenced completions: `git checkout`, `git switch`, `git merge`

---

Screenshot: 

![](https://github.com/user-attachments/assets/f4030039-87f3-46fd-841c-b961edf4c37a)

Should resolve #1041

Screenshot from before, showing a wrong classification of a local branch
as remote branch:


![](https://github.com/user-attachments/assets/7cbb9545-fe24-48eb-9772-1bba775fcf29)
2025-04-19 06:52:43 -05:00
Nguyễn Hồng Quân
1da73cf106
Add compatibility note about Nu version (#1057)
This is my response for #1051 

The syntax of this note is inspired by Rust _Cargo.toml_ and Python
_pyproject.toml_.
2025-02-24 06:27:50 -06:00
Nguyễn Hồng Quân
1e7fdd4427
Improve completer speed for git checkout (#1054)
Improvement:
- Faster to give result (calling `git` less, telling `git` to return
simpler-to-parse output).
- Context aware. For example:
+ After `git checkout branch-name`, the rest arguments must be file
paths (`git checkout` only accepts one "branch").
  + After `--` are file paths. `git checkout a-branch -- a-file`

The current completer for `git checkout` is slow because:
- Running `git` too many times.
- Parse many results and end up not use.


![image](https://github.com/user-attachments/assets/48b8542b-0080-4962-a660-2a13e9cb76ea)


![image](https://github.com/user-attachments/assets/8e55e3cf-70bc-404a-b303-7a13d811b5fd)
2025-02-22 07:29:04 -06:00
Nguyễn Hồng Quân
c85083919e
Autocomplete for "git merge". (#1048)
Just support most often-used options and flags, though.


![image](https://github.com/user-attachments/assets/e9d411b7-6665-4796-bd7e-f06a80d06b73)


![image](https://github.com/user-attachments/assets/780482af-0022-4c16-9ffa-bc78a041c2de)
2025-02-16 07:21:30 -06:00
Nguyễn Hồng Quân
07050f877f
Provide completion for git subcommands (#1044)
This is to provide completion for when user types `git [Tab]`.
There is already completion for `git help [Tab]` but I don't know why
author don't add it to `git` alone.

Fixes #1043
2025-02-13 20:54:25 -06:00
Dave
e6da07f512
Add git reset completion (#1027)
Added a git completion for git reset.
2025-01-28 08:53:33 -06:00
Auca Coyan
fff77c7da6
unsort the completions in git checkout (#1022)
### motivation
Hi! This is something I wanted since [#14424 of
nushell/nushell](https://github.com/nushell/nushell/pull/14424) landed.
Unsorted completions on the `git checkout` command

### The problem
is that git checkout accepts lots of things: commits hashes, filenames,
local branches and remote branches. Since the mentioned pr all the
completions were sorted, but for this command it didn't make sense.
I used `git switch` to checkout a branch for the time being, but it's a
little annoying that you can't push "unsorted" completions on a command.

### the result

With the help of ysthakur and weirdan, I managed to achieve this:
```
git checkout <tab>
```

before: (these are sorted)

![image](https://github.com/user-attachments/assets/ad495b29-e418-426f-9bbe-2056f34b819f)

after: (these aren't)

![image](https://github.com/user-attachments/assets/e2b5d647-cccb-4e0b-b1c2-b80781ada3ec)

### How?
Citing the docs:

https://www.nushell.sh/book/custom_completions.html#options-for-custom-completions

```
    {
        options: {
            case_sensitive: false,
            completion_algorithm: prefix,
            positional: false,
            sort: false,
        },
        completions: [cat, rat, bat]
    }
}
```

and I passed **a table** to the `completions` key, instead of a _list_.

```
    completions: $table_of_checkouts
```
2025-01-26 21:27:36 -06:00
Auca Coyan
b42f2bd5c1
remove gstat dependency from git-aliases (#1020)
I removed `gstat` plugin dependency need by replacing the command.

~~The only problem is that the aliases don't work for the current
nushell version~~
Done!


fixes #973 and closes #974
2025-01-25 13:23:57 -06:00
Auca Coyan
759218de6f
🐛 fix additional + in git local branches (#1019)
Hi! I realized if you use worktrees, with at least one branch checked
out and you:
```
git switch <tab>
```
the autocompletion is wrong, putting a `+ ` before the branch, and
piping it into the cmdline.

This comes from `nu-complete git local branches` function, it which it
only replaces `* ` for the current branch, but it doesn't for `+ ` for
worktrees.
Here is a sample:


![image](https://github.com/user-attachments/assets/814c728b-82da-4d15-9f22-ff0fd5a92ae1)

I tested on my pc and works allright!
2025-01-25 08:32:26 -06:00
Loïc Riegel
62c3aa7403
Fix: remove duplicate in git-completions.nu (#1016)
This remove a duplicate: the `--no-edit` was there twice in the "git
commit" command completion.
After my change, the only remaining `--no-edit` is at line 455.
2025-01-15 20:58:54 -06:00
Marc Schreiber
e10ffbaaa7
Fix git diff completions (#962)
Fixes #961
2024-09-26 11:18:04 -05:00
Auca Coyan
da307d0864
🩹 fix git init --initial-branch string instead of bool (#959)
Just using the completions I realized that:

```nu
# Create a new git repository
export extern "git init" [
  --initial-branch(-b)                                # initial branch name
  #should be
  --initial-branch(-b): string                        # initial branch name
]
```

because initial branch takes a string, it not a boolean
2024-09-22 15:15:37 -05:00
chtenb
430951c3b1
Use --no-color for git completions (#943)
Resolves https://github.com/nushell/nu_scripts/issues/942
2024-08-29 09:10:50 -05:00
Loïc Riegel
6abc543722
Add custom completions for pre-commit (#940)
# Added

Completions for pre-commit, plus README

# Fixed

Removed duplciate flag it git completionts
2024-08-25 18:27:18 -05:00
Auca Coyan
0cba7933f2
add worktree completions (#933)
you can now `git worktree remove <tab>` for autocompletions

![image](https://github.com/user-attachments/assets/2eac159c-fd86-42c4-9ecc-469b333dea52)

and show the branches _after_ the path in `git worktree add ./my-path
<tab>`

![image](https://github.com/user-attachments/assets/d5fadce3-8153-4d51-82e3-0a911ecdefb6)
2024-08-14 15:40:59 -05:00
Okdro
0906f7a15c
Feature/add git grep completions (#898)
Added completions for most of the flags for `git grep`. 

A few flags have been omitted for this PR due to Git expecting arguments
for those be passed without whitespaces. The arguments are optional, but
the flags would not work when passed arguments (see `--open-with-pager`
and `--color` flags in [this
commit](ffa9ceab73)
for how I tried to do it).

Ex. 

`--open-with-pager(-O)` expects the optional argument to be passed as
either `--open-with-pager=<pager>` or `-O<pager>`. Including it in the
completions list as I had implemented it breaks the flag when using the
optional parameter.

Feedback appreciated for how to handle that. I'm still new to the Nu
language, so I might have missed something obvious that could fix that.
2024-07-21 06:59:39 -05:00
OJarrisonn_
8d8a865b38
fix: nu-complete for git ref and git files-and-ref uses nu-complete git switch now (#906)
Git `nu-complete` defs where outdated, using a removed function
`nu-complete git switachable branches`, now using `nu-complete git
switch`

Already tested (except for tags)
2024-07-21 06:35:26 -05:00
Okdro
7471b4d966
Added Git completions for the restore subcommand (#895)
Added `git restore` to git completions, as I was missing tab completion
for that.

I've begun to use Nushell regularly, so I hope this addition will be
useful to others as it is to me.

Feedback is appreciated if there's any conventions I've missed, or
options that need better wording.
2024-07-16 12:20:00 -05:00
Darren Schroeder
a1c3ace432
Revert "Revert "Add git coommit completions"" (#869)
Reverts nushell/nu_scripts#868

I found that this works, if you source these files like
```
use aliases/git/git-aliases.nu *
use custom-completions/git/git-completions.nu *
```
but if you source them like this, it doesn't work.
```
use custom-completions/git/git-completions.nu *
use aliases/git/git-aliases.nu *
```

This changed recently somewhere in nushell.
2024-06-05 07:41:42 -05:00
Darren Schroeder
5adf14dab9
Revert "Add git coommit completions" (#868)
Reverts nushell/nu_scripts#854

This PR broke the git aliases
https://github.com/nushell/nu_scripts/blob/main/aliases/git/git-aliases.nu
so I'm reverting it.
2024-06-05 07:21:14 -05:00
laisnuto
95670ddfcb
Complete git pull (#866)
Create compleations for git pull
2024-06-04 19:47:38 -05:00
OJarrisonn_
f6ec482ea3
feat: git clone completions (#856)
Adds completions for the `git clone` command
2024-05-28 06:35:27 -05:00
laisnuto
5ce769ca2c
Add git coommit completions (#854)
Improve git commit completions for nushell
2024-05-28 06:33:48 -05:00
Maxim Uvarov
afde2592a6
use typos for corrections (#833)
I used [typos](https://github.com/crate-ci/typos/).
I manually checked all the corrections and they seem safe to me.
There are still some left, but those in this PR are good
2024-05-08 06:47:54 -05:00
zhangym
8c9d0e13bf
feat: add git worktree command (#824) 2024-04-25 07:44:17 -05:00
Auca Coyan
6585a0f515
🐛 fix optional arg in git stash show (#765)
Hi! Another bug I found, in `git`, you can
```bash
git stash show
```
with no args and should be alright, but the .nu script is requiring a
git name. (maybe for a previous version of git it was needed)
2024-02-26 15:42:28 -06:00
Darren Schroeder
a690fcbaa9
do not require stash in git stash drop (#732)
This fixes a small bug so that `git stash drop` doesn't _require_ a
stash
2024-01-11 07:45:11 -06:00
Faïz Hernawan
8635a78991
completions/git: fix support for path relative to current directory (#666)
Continuing effort on https://github.com/nushell/nu_scripts/pull/617
which only auto-completes path relative to git root.

Before,

```
$ cd src/

$ git add <tab>
src/main.rs    Modified
README.md      Untracked

$ git diff <tab>
src/main.rs
```

Now it displays,
```
$ cd src/

$ git add <tab>
main.rs           Modified
../README.md      Untracked

$ git diff <tab>
main.rs
```
2023-11-14 06:25:00 -06:00
Darren Schroeder
310b1df564
fix conflicts between git-completions.nu and git-aliases.nu (#651)
This PR fixes the conflicts between git-completions.nu and
git-aliases.nu.

Prior to this PR you would see problems like this
```nushell
❯ use custom-completions\git\git-completions.nu *
❯ use aliases\git\git-aliases.nu
Error: nu::parser::missing_flag_param

  × Missing flag argument.
    ╭─[D:\nu_scripts\aliases\git\git-aliases.nu:64:1]
 64 │ export alias gco = git checkout
 65 │ export alias gcor = git checkout --recurse-submodules
    ·                                  ──────────┬─────────
    ·                                            ╰── flag missing string argument
 66 │ export alias gcount = git shortlog --summary --numbered
    ╰────
```
This is because, in this example, in git-completions.nu, there is a
custom command named `git checkout` that takes a `--recurse-submodules:
string` parameter, which means it's expecting a string. Removing the `:
string` part fixes the issue and allows the files to be sourced/used as
expected.

This seems more like a hack than a fix. I'm not sure if this behavior is
intended or not, but this PR fixes it anyway.

close #493
2023-10-26 15:11:47 -05:00
Marc Schreiber
9ceac61989
Fix git-completions.nu (#620)
The parsing of local git branches accidentally escaped an asterisks
because it had been used as an regular expression in the past.
2023-09-25 06:39:43 -05:00
Faïz Hernawan
9d0a182a86
completions/git: add filename completion to diff and checkout (#617) 2023-09-22 16:29:05 -05:00
Noah
4cbd678d78
Expand git completions (#587)
* Complete popping a particular stash

* Add some missing git completions

* Git prune subcommand

* Add filepath completion for `git add`
2023-08-31 07:46:59 -05:00
sgasse
9f480c470f
custom-completions: git: Expand completions (#407)
The different commands such as `git checkout`, `git switch`, `git
cherry-pick` and `git rebase` all accept slightly differing refspecs.
This commit separates the extraction of refspecs and combines them in
individual completion commands for the different external commands.

All git commands complete with a table of `value | description` now.

Addresses #406

Co-authored-by: Simon Gasse <sgasse@users.noreply.github.com>
2023-03-29 06:42:19 -05:00
David Lattimore
1884426d79
git-completions: Add completions for more subcommands (#420)
Added branch, remote, diff, commit, pull, stash, init, status, add, rm,
help, log, bisect

Also removed ? from `git rebase --onto` which was putting a literal `?`
into the flag when completing.
2023-03-21 07:37:08 -05:00
sgasse
471c81c5ff
custom-completions: git: Add git rebase (#404)
Co-authored-by: Simon Gasse <sgasse@users.noreply.github.com>
2023-03-12 12:22:52 +01:00
Hofer-Julian
dc87ff276c
git-completions: Stop checking --force-with-lease (#362) 2023-01-25 06:22:50 -06:00
Marc Schreiber
6801071f50
Fix git checkout/switch completions (#359) 2023-01-24 06:02:58 -06:00
Marc Schreiber
e89b4ac6be
Improve git checkout/switch completions (#358) 2023-01-23 06:05:43 -06:00
Antoine Stevan
89c209f89e
add the "export" keyword to "extern git cherry-pick" (#356) 2023-01-21 13:16:23 -06:00
Marc Schreiber
a023cea71a
Add git cherry-pick completion (#355) 2023-01-21 07:19:52 -06:00
Arnout Engelen
47edd7dbbc
custom completions: git: 'git fetch' (#210) 2022-04-21 00:11:45 +02:00
Justin Ma
af33063bf3
Fix completions for git push and git checkout (#204) 2022-04-14 08:18:19 -05:00
Darren Schroeder
e6d8d2704e
update scripts to support str replace (#200) 2022-04-07 08:45:04 -05:00
Darren Schroeder
7320f99f59
update completions (#193)
move the rest of the completions to module syntax
2022-03-28 07:57:54 -05:00
Darren Fuller
c58ca9c446
add git switch completion (#190) 2022-03-27 12:08:33 -05:00
JT
09abce0d18
Update git-completions.nu 2022-03-03 15:29:10 -05:00
Darren Schroeder
cdacab3df9
tweak git completions (#166) 2022-02-27 16:16:53 -06:00
Darren Schroeder
ca89da5242
reorganize site in preparation for beta and releaes (#161) 2022-02-25 13:10:38 -06:00