Add aliases

main
Julius Riegel 1 month ago
parent 3adff68faf
commit c0d374f8ed

@ -6,3 +6,16 @@ source ./git.nu
{{#if-installed podman}}
source ./podman.nu
{{/if-installed}}
{{#if-installed npm}}
source ./npm.nu
{{/if-installed}}
{{#if-installed gh}}
source ./gh.nu
{{/if-installed}}
{{#if-installed zellij}}
source ./zellij.nu
{{/if-installed}}

@ -0,0 +1,549 @@
def "nu-complete gh" [] {
^gh --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh" [
command?: string@"nu-complete gh"
--help # Show help for command
]
def "nu-complete gh auth" [] {
^gh auth --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh auth" [
command?: string@"nu-complete gh auth"
--help # Show help for command
]
export extern "gh browse" [
command?: string # TODO: completion with [<PR number> | <file path> | <commit-SHA>]
--branch(-b) # Select another branch by passing in the branch name
--commit(-c) # Select another commit by passing in the commit SHA, default is the last commit
--no-browser(-n) # Print destination URL instead of opening the browser
--projects(-p) # Open repository projects
--releases(-r) # Open repository releases
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--settings(-s) # Open repository settings
--wiki(-w) # Open repository wiki
--help # Show help for command
]
def "nu-complete gh codespace" [] {
^gh codespace --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh codespace" [
command?: string@"nu-complete gh codespace"
--help # Show help for command
]
def "nu-complete gh gist" [] {
^gh gist --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh gist" [
command?: string@"nu-complete gh gist"
--help # Show help for command
]
export extern "gh gist clone" [
gist: string # gist to clone
directory?:path # directory to clone
--help # Show help for command
]
export extern "gh gist create" [
filename_or_stdin: string # gist to create
--desc(-d): string # A description for this gist
--filename(-f): string # Provide a filename to be used when reading from standard input
--public(-p) # List the gist publicly (default: secret)
--web(-w) # Open the web browser with created gist
--public # Make the new gist public
--help # Show help for command
]
export extern "gh gist delete" [
gist: string@"nu-complete gist list" # gist to delete
--help # Show help for command
]
export extern "gh gist edit" [
gist: string@"nu-complete gist list" # gist to edit
--add(-a): string # Add a new file to the gist
--desc(-d): string # New description for the gist
--filename(-f): string # Select a file to edit
--remove(-r): string # Remove a file from the gist
--help # Show help for command
]
def "nu-complete gist list" [] {
# TODO add the name of the gist to autocompletion
^gh gist list --limit 100 | lines | str replace --regex --multiline '\S+\K.*' ''
}
export extern "gh gist list" [
--limit(-L): number # Maximum number of repositories to list (default 30)
--public # Show only the public gists
--secret # Show only the secret gists
--help # Show help for command
]
export extern "gh gist rename" [
gist: string # gist to rename
oldFilename: string # gist to rename
newFilename: string # gist to rename
--help # Show help for command
]
export extern "gh gist view" [
gist?: string # gist to view
--filename(-f): string # Display a single file from the gist
--files # List file names from the gist
--raw(-r) # Print raw instead of rendered gist contents
--web(-w) # Open gist in the browser
--help # Show help for command
]
def "nu-complete gh issue" [] {
^gh issue --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh issue" [
command?: string@"nu-complete gh issue"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh org" [] {
^gh org --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh org" [
command?: string@"nu-complete gh org"
--help # Show help for command
]
def "nu-complete gh pr" [] {
^gh pr --help | lines | filter { str starts-with " " } | skip 1 | parse "{value}: {description}" | str trim
}
export extern "gh pr" [
command?: string@"nu-complete gh pr"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh list prs" [] {
gh pr list --json title,number,author,updatedAt | from json | update author {|row| $row.author.login } | rename --column { number: value } | insert description { |row| ( $row.updatedAt | date humanize) + " - " + $row.title + " by " + $row.author } | select value description
}
export extern "gh pr checkout" [
branch_url_or_PRnumber: string@"nu-complete gh list prs" # {<number> | <url> | <branch>}
--branch(-b): string # Local branch name to use (default: the name of the head branch)
--detach # Checkout PR with a detached HEAD
--force(-f) # Reset the existing local branch to the latest state of the pull request
--recurse-submodules # Update all submodules after checkout
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh project" [] {
^gh project --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh project" [
command?: string@"nu-complete gh project"
--help # Show help for command
]
def "nu-complete gh release" [] {
^gh release --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh release" [
command?: string@"nu-complete gh release"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh repo" [] {
^gh repo --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh repo" [
command?: string@"nu-complete gh repo"
--help # Show help for command
]
def "nu-complete gh repo clone" [] {
# regex that actually works
# ^(?P<value>\S+) +(?P<description>\S+( \S+)*)? {2,}(?P<Visibility>public|private),?.*(?P<updated>about.*)
^gh repo list --limit 100 | lines | str replace --regex --multiline '\S+\K.*' ''
}
export extern "gh repo clone" [
command: string@"nu-complete gh repo clone"
--help # Show help for command
]
def "nu-complete visibility" [] {
['public', 'private', 'internal']
}
export extern "gh repo list" [
owner?: string # List repos of this owner
--archived # Show only archived repositories
--fork # Show only forks
--jq(-q):string # Filter JSON output using a jq expression
--json: string # Output JSON with the specified fields
--language(-l): string # Filter by primary coding language
--limit(-L): number # Maximum number of repositories to list (default 30)
--no-archived # Omit archived repositories
--source # Show only non-forks
--template(-t): string # Format JSON output using a Go template; see "gh help formatting"
--topic: string # Filter by topic
--visibility: string@"nu-complete visibility" # Filter by repository visibility: {public|private|internal}
--help # Show help for command
]
export extern "gh repo view" [
org_repo: string # <ORG/REPO> to view
--branch(-b):string # View a specific branch of the repository
--jq(-q):string # Filter JSON output using a jq expression
--json: string # Output JSON with the specified fields
--template(-t):string # Format JSON output using a Go template; see "gh help formatting"
--web # Open a repository in the browser
--help # Show help for command
]
def "nu-complete gitignore list" [] {
^gh api -H "Accept: application/vnd.github+json" /gitignore/templates
| from json
}
def "nu-complete licenses list" [] {
let value = ^gh api -H "Accept: application/vnd.github+json" /licenses | from json | get key | enumerate | reject index | rename value
let description = ^gh api -H "Accept: application/vnd.github+json" /licenses | from json | get name | enumerate | reject index | rename description
$value | merge $description
}
export extern "gh repo create" [
repo_name?: string
--help # Show help for command
--add-readme # Add a README file to the new repository
--clone(-c) # Clone the new repository to the current directory
--description(-d): string # Description of the repository
--disable-issues # Disable issues in the new repository
--disable-wiki # Disable wiki in the new repository
--gitignore(-g): string@"nu-complete gitignore list" # Specify a gitignore template for the repository
--homepage(-g): string # Repository home page URL
--include-all-branches # Include all branches from template repository
--internal # Make the new repository internal
--license(-l): string@"nu-complete licenses list" # Specify an Open Source License for the repository
--private # Make the new repository private
--public # Make the new repository public
--push # Push local commits to the new repository
--remote(-r): string # Specify remote name for the new repository
--source(-s): string # Specify path to local repository to use as source
--team(-t): string # The name of the organization team to be granted access
--template(-p): string # Make the new repository based on a template repository
]
export extern "gh repo fork" [
repo?: string
--clone # Clone the fork
--default-branch-only # Only include the default branch in the fork
--fork-name: string # Rename the forked repository
--org: string # Create the fork in an organization
--remote # Add a git remote for the fork
--remote-name: string # Specify the name for the new remote (default "origin")
--help # Show help for command
]
def "nu-complete gh cache" [] {
^gh cache --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh cache" [
command?: string@"nu-complete gh cache"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh run" [] {
^gh run --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh run" [
command?: string@"nu-complete gh run"
--help # Show help for command
]
def "nu-complete gh workflow" [] {
^gh workflow --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh workflow" [
command?: string@"nu-complete gh workflow"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh alias" [] {
^gh alias --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh alias" [
command?: string@"nu-complete gh alias"
--help # Show help for command
]
def "nu-complete gh api" [] {
# TODO
# endpoints
# ["graphql", "gists"]
}
export extern "gh api" [
--cache # Cache the response, e.g. "3600s", "60m", "1h"
--field(-F) # `key=value` Add a typed parameter in key=value format
--header(-H) # `key:value` Add a HTTP request header in key:value format
--hostname # The GitHub hostname for the request (default "github.com")
--include(-i) # Include HTTP response status line and headers in the output
--input file # The file to use as body for the HTTP request (use "-" to read from standard input)
--jq(-q) # Query to select values from the response using jq syntax
--method(-X) # The HTTP method for the request (default "GET")
--paginate # Make additional HTTP requests to fetch all pages of results
--preview(-p) # GitHub API preview names to request (without the "-preview" suffix)
--raw-field(-f) # `key:value` Add a string parameter in key=value format
--silent # Do not print the response body
--template(-t) # Format JSON output using a Go template; see "gh help formatting"
--verbose # Include full HTTP request and response in the output
--help # Show help for command
command?: string@"nu-complete gh api"
]
def "nu-complete gh completion" [] {
['bash', 'fish', 'powershell', 'zsh']
}
export extern "gh completion" [
command?: string@"nu-complete gh completion"
--shell(-s) # Shell type: {bash|zsh|fish|powershell}
--help # Show help for command
]
def "nu-complete gh config" [] {
^gh config --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh config" [
command?: string@"nu-complete gh config"
--help # Show help for command
]
def "nu-complete gh extension" [] {
^gh extension --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh extension" [
command?: string@"nu-complete gh extension"
--help # Show help for command
]
def "nu-complete gh gpg-key" [] {
^gh gpg-key --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh gpg-key" [
command?: string@"nu-complete gh gpg-key"
--help # Show help for command
]
def "nu-complete gh label" [] {
^gh label --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh label" [
command?: string@"nu-complete gh label"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh ruleset" [] {
^gh ruleset --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh ruleset" [
command?: string@"nu-complete gh ruleset"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh search" [] {
^gh search --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh search" [
--extension # Filter on file extension
--filename # Filter on filename
--jq(-q) # Filter JSON output using a jq expression
--json # Output JSON with the specified fields
--language # Filter results by language
--limit(-L) # Maximum number of code results to fetch (default 30)
--match # Restrict search to file contents or file path: {file|path}
--owner # Filter on owner
--repo(-R) # Filter on repository
--size # Filter on size range, in kilobytes
--template(-t) # Format JSON output using a Go template; see "gh help formatting"
--web(-w) a # Open the search query in the web browser
--help # Show help for command
command?: string@"nu-complete gh search"
]
def "nu-complete gh secret" [] {
^gh secret --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh secret" [
command?: string@"nu-complete gh secret"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]
def "nu-complete gh ssh-key" [] {
^gh ssh-key --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh ssh-key" [
command?: string@"nu-complete gh ssh-key"
--help # Show help for command
]
export extern "gh status" [
--exclude(-e) # Comma separated list of repos to exclude in owner/name format
--org(-o) # Report status within an organization
--help # Show help for command
]
def "nu-complete gh variable" [] {
^gh variable --help
| lines
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
}
export extern "gh variable" [
command?: string@"nu-complete gh variable"
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]

@ -1,20 +1,184 @@
# Custom completions for external commands (those outside of Nushell)
# Each completions has two parts: the form of the external command, including its flags and parameters
# and a helper command that knows how to complete values for those flags and parameters
#
# This is a simplified version of completions for git branches and git remotes
def "nu-complete git branches" [] {
^git branch | lines | each { |line| $line | str replace '[\*\+] ' '' | str trim }
def "nu-complete git available upstream" [] {
^git branch -a | lines | each { |line| $line | str replace '\* ' "" | str trim }
}
def "nu-complete git remotes" [] {
^git remote | lines | each { |line| $line | str trim }
}
def "nu-complete git log" [] {
^git log --pretty=%h | lines | each { |line| $line | str trim }
}
# Yield all existing commits in descending chronological order.
def "nu-complete git commits all" [] {
^git rev-list --all --remotes --pretty=oneline | lines | parse "{value} {description}"
}
# Yield commits of current branch only. This is useful for e.g. cut points in
# `git rebase`.
def "nu-complete git commits current branch" [] {
^git log --pretty="%h %s" | lines | parse "{value} {description}"
}
# Yield local branches like `main`, `feature/typo_fix`
def "nu-complete git local branches" [] {
^git branch | lines | each { |line| $line | str replace '* ' "" | str trim }
}
# Yield remote branches like `origin/main`, `upstream/feature-a`
def "nu-complete git remote branches with prefix" [] {
^git branch -r | lines | parse -r '^\*?(\s*|\s*\S* -> )(?P<branch>\S*$)' | get branch | uniq
}
# Yield remote branches *without* prefix which do not have a local counterpart.
# E.g. `upstream/feature-a` as `feature-a` to checkout and track in one command
# with `git checkout` or `git switch`.
def "nu-complete git remote branches nonlocal without prefix" [] {
# Get regex to strip remotes prefixes. It will look like `(origin|upstream)`
# for the two remotes `origin` and `upstream`.
let remotes_regex = (["(", ((nu-complete git remotes | each {|r| [$r, '/'] | str join}) | str join "|"), ")"] | str join)
let local_branches = (nu-complete git local branches)
^git branch -r | lines | parse -r (['^[\* ]+', $remotes_regex, '?(?P<branch>\S+)'] | flatten | str join) | get branch | uniq | where {|branch| $branch != "HEAD"} | where {|branch| $branch not-in $local_branches }
}
def "nu-complete git switch" [] {
(nu-complete git local branches)
| parse "{value}"
| insert description "local branch"
| append (nu-complete git remote branches nonlocal without prefix
| parse "{value}"
| insert description "remote branch")
}
def "nu-complete git checkout" [] {
(nu-complete git local branches)
| parse "{value}"
| insert description "local branch"
| append (nu-complete git remote branches nonlocal without prefix
| parse "{value}"
| insert description "remote branch")
| append (nu-complete git remote branches with prefix
| parse "{value}"
| insert description "remote branch")
| append (nu-complete git commits all)
| append (nu-complete git files | where description != "Untracked" | select value)
}
# Arguments to `git rebase --onto <arg1> <arg2>`
def "nu-complete git rebase" [] {
(nu-complete git local branches)
| parse "{value}"
| insert description "local branch"
| append (nu-complete git remote branches with prefix
| parse "{value}"
| insert description "remote branch")
| append (nu-complete git commits all)
}
def "nu-complete git stash-list" [] {
git stash list | lines | parse "{value}: {description}"
}
def "nu-complete git tags" [] {
^git tag | lines
}
# See `man git-status` under "Short Format"
# This is incomplete, but should cover the most common cases.
const short_status_descriptions = {
".D": "Deleted"
".M": "Modified"
"!" : "Ignored"
"?" : "Untracked"
"AU": "Staged, not merged"
"MD": "Some modifications staged, file deleted in work tree"
"MM": "Some modifications staged, some modifications untracked"
"R.": "Renamed"
"UU": "Both modified (in merge conflict)"
}
def "nu-complete git files" [] {
let relevant_statuses = ["?",".M", "MM", "MD", ".D", "UU"]
^git status -uall --porcelain=2
| lines
| each { |$it|
if $it starts-with "1 " {
$it | parse --regex "1 (?P<short_status>\\S+) (?:\\S+\\s?){6} (?P<value>\\S+)"
} else if $it starts-with "2 " {
$it | parse --regex "2 (?P<short_status>\\S+) (?:\\S+\\s?){6} (?P<value>\\S+)"
} else if $it starts-with "u " {
$it | parse --regex "u (?P<short_status>\\S+) (?:\\S+\\s?){8} (?P<value>\\S+)"
} else if $it starts-with "? " {
$it | parse --regex "(?P<short_status>.{1}) (?P<value>.+)"
} else {
{ short_status: 'unknown', value: $it }
}
}
| flatten
| where $it.short_status in $relevant_statuses
| insert "description" { |e| $short_status_descriptions | get $e.short_status}
}
def "nu-complete git built-in-refs" [] {
[HEAD FETCH_HEAD ORIG_HEAD]
}
def "nu-complete git refs" [] {
nu-complete git switchable branches
| parse "{value}"
| insert description Branch
| append (nu-complete git tags | parse "{value}" | insert description Tag)
| append (nu-complete git built-in-refs)
}
def "nu-complete git files-or-refs" [] {
nu-complete git switchable branches
| parse "{value}"
| insert description Branch
| append (nu-complete git files | where description == "Modified" | select value)
| append (nu-complete git tags | parse "{value}" | insert description Tag)
| append (nu-complete git built-in-refs)
}
def "nu-complete git subcommands" [] {
^git help -a | lines | where $it starts-with " " | parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
}
def "nu-complete git add" [] {
nu-complete git files
}
# Check out git branches and files
export extern "git checkout" [
...targets: string@"nu-complete git checkout" # name of the branch or files to checkout
--conflict: string # conflict style (merge or diff3)
--detach(-d) # detach HEAD at named commit
--force(-f) # force checkout (throw away local modifications)
--guess # second guess 'git checkout <no-such-branch>' (default)
--ignore-other-worktrees # do not check if another worktree is holding the given ref
--ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only
--merge(-m) # perform a 3-way merge with the new branch
--orphan: string # new unparented branch
--ours(-2) # checkout our version for unmerged files
--overlay # use overlay mode (default)
--overwrite-ignore # update ignored files (default)
--patch(-p) # select hunks interactively
--pathspec-from-file: string # read pathspec from file
--progress # force progress reporting
--quiet(-q) # suppress progress reporting
--recurse-submodules # control recursive updating of submodules
--theirs(-3) # checkout their version for unmerged files
--track(-t) # set upstream info for new branch
-b # create and checkout a new branch
-B: string # create/reset and checkout a branch
-l # create reflog for new branch
]
# Download objects and refs from another repository
export extern "git fetch" [
repository?: string@"nu-complete git remotes" # name of the repository to fetch
branch?: string@"nu-complete git branches" # name of the branch to fetch
repository?: string@"nu-complete git remotes" # name of the branch to fetch
--all # Fetch all remotes
--append(-a) # Append ref names and object names to .git/FETCH_HEAD
--atomic # Use an atomic transaction to update local refs.
@ -58,64 +222,272 @@ export extern "git fetch" [
--no-show-forced-updates # Don't check if a branch is force-updated
-4 # Use IPv4 addresses, ignore IPv6 addresses
-6 # Use IPv6 addresses, ignore IPv4 addresses
--help # Display this help message
]
# Check out git branches and files
export extern "git checkout" [
...targets: string@"nu-complete git branches" # name of the branch or files to checkout
--conflict: string # conflict style (merge or diff3)
--detach(-d) # detach HEAD at named commit
--force(-f) # force checkout (throw away local modifications)
--guess # second guess 'git checkout <no-such-branch>' (default)
--ignore-other-worktrees # do not check if another worktree is holding the given ref
--ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only
--merge(-m) # perform a 3-way merge with the new branch
--orphan: string # new unparented branch
--ours(-2) # checkout our version for unmerged files
--overlay # use overlay mode (default)
--overwrite-ignore # update ignored files (default)
--patch(-p) # select hunks interactively
--pathspec-from-file: string # read pathspec from file
--progress # force progress reporting
--quiet(-q) # suppress progress reporting
--recurse-submodules: string # control recursive updating of submodules
--theirs(-3) # checkout their version for unmerged files
--track(-t) # set upstream info for new branch
-b: string # create and checkout a new branch
-B: string # create/reset and checkout a branch
-l # create reflog for new branch
--help # Display this help message
]
# Push changes
export extern "git push" [
remote?: string@"nu-complete git remotes", # the name of the remote
...refs: string@"nu-complete git branches" # the branch / refspec
--all # push all refs
--atomic # request atomic transaction on remote side
--delete(-d) # delete refs
--dry-run(-n) # dry run
--exec: string # receive pack program
--follow-tags # push missing but relevant tags
--force-with-lease: string # require old value of ref to be at this value
--force(-f) # force updates
--ipv4(-4) # use IPv4 addresses only
--ipv6(-6) # use IPv6 addresses only
--mirror # mirror all refs
--no-verify # bypass pre-push hook
--porcelain # machine-readable output
--progress # force progress reporting
--prune # prune locally removed refs
--push-option(-o): string # option to transmit
--quiet(-q) # be more quiet
--receive-pack: string # receive pack program
--recurse-submodules: string # control recursive pushing of submodules
--repo: string # repository
--set-upstream(-u) # set upstream for git pull/status
--signed: string # GPG sign the push
--tags # push tags (can't be used with --all or --mirror)
--thin # use thin pack
--verbose(-v) # be more verbose
--help # Display this help message
remote?: string@"nu-complete git remotes", # the name of the remote
...refs: string@"nu-complete git local branches" # the branch / refspec
--all # push all refs
--atomic # request atomic transaction on remote side
--delete(-d) # delete refs
--dry-run(-n) # dry run
--exec: string # receive pack program
--follow-tags # push missing but relevant tags
--force-with-lease # require old value of ref to be at this value
--force(-f) # force updates
--ipv4(-4) # use IPv4 addresses only
--ipv6(-6) # use IPv6 addresses only
--mirror # mirror all refs
--no-verify # bypass pre-push hook
--porcelain # machine-readable output
--progress # force progress reporting
--prune # prune locally removed refs
--push-option(-o): string # option to transmit
--quiet(-q) # be more quiet
--receive-pack: string # receive pack program
--recurse-submodules: string # control recursive pushing of submodules
--repo: string # repository
--set-upstream(-u) # set upstream for git pull/status
--signed: string # GPG sign the push
--tags # push tags (can't be used with --all or --mirror)
--thin # use thin pack
--verbose(-v) # be more verbose
]
# Pull changes
export extern "git pull" [
remote?: string@"nu-complete git remotes", # the name of the remote
...refs: string@"nu-complete git local branches" # the branch / refspec
--rebase # rebase current branch on top of upstream after fetching
]
# Switch between branches and commits
export extern "git switch" [
switch?: string@"nu-complete git switch" # name of branch to switch to
--create(-c) # create a new branch
--detach(-d): string@"nu-complete git log" # switch to a commit in a detatched state
--force-create(-C): string # forces creation of new branch, if it exists then the existing branch will be reset to starting point
--force(-f) # alias for --discard-changes
--guess # if there is no local branch which matches then name but there is a remote one then this is checked out
--ignore-other-worktrees # switch even if the ref is held by another worktree
--merge(-m) # attempts to merge changes when switching branches if there are local changes
--no-guess # do not attempt to match remote branch names
--no-progress # do not report progress
--no-recurse-submodules # do not update the contents of sub-modules
--no-track # do not set "upstream" configuration
--orphan: string # create a new orphaned branch
--progress # report progress status
--quiet(-q) # suppress feedback messages
--recurse-submodules # update the contents of sub-modules
--track(-t) # set "upstream" configuration
]
# Apply the change introduced by an existing commit
export extern "git cherry-pick" [
commit?: string@"nu-complete git commits all" # The commit ID to be cherry-picked
--edit(-e) # Edit the commit message prior to committing
--no-commit(-n) # Apply changes without making any commit
--signoff(-s) # Add Signed-off-by line to the commit message
--ff # Fast-forward if possible
--continue # Continue the operation in progress
--abort # Cancel the operation
--skip # Skip the current commit and continue with the rest of the sequence
]
# Rebase the current branch
export extern "git rebase" [
branch?: string@"nu-complete git rebase" # name of the branch to rebase onto
upstream?: string@"nu-complete git rebase" # upstream branch to compare against
--continue # restart rebasing process after editing/resolving a conflict
--abort # abort rebase and reset HEAD to original branch
--quit # abort rebase but do not reset HEAD
--interactive(-i) # rebase interactively with list of commits in editor
--onto?: string@"nu-complete git rebase" # starting point at which to create the new commits
--root # start rebase from root commit
]
# List or change branches
export extern "git branch" [
branch?: string@"nu-complete git local branches" # name of branch to operate on
--abbrev # use short commit hash prefixes
--edit-description # open editor to edit branch description
--merged # list reachable branches
--no-merged # list unreachable branches
--set-upstream-to: string@"nu-complete git available upstream" # set upstream for branch
--unset-upstream # remote upstream for branch
--all # list both remote and local branches
--copy # copy branch together with config and reflog
--format # specify format for listing branches
--move # rename branch
--points-at # list branches that point at an object
--show-current # print the name of the current branch
--verbose # show commit and upstream for each branch
--color # use color in output
--quiet # suppress messages except errors
--delete(-d) # delete branch
--list # list branches
--contains: string@"nu-complete git commits all" # show only branches that contain the specified commit
--no-contains # show only branches that don't contain specified commit
--track(-t) # when creating a branch, set upstream
]
# List or change tracked repositories
export extern "git remote" [
--verbose(-v) # Show URL for remotes
]
# Add a new tracked repository
export extern "git remote add" [
]
# Rename a tracked repository
export extern "git remote rename" [
remote: string@"nu-complete git remotes" # remote to rename
new_name: string # new name for remote
]
# Remove a tracked repository
export extern "git remote remove" [
remote: string@"nu-complete git remotes" # remote to remove
]
# Get the URL for a tracked repository
export extern "git remote get-url" [
remote: string@"nu-complete git remotes" # remote to get URL for
]
# Set the URL for a tracked repository
export extern "git remote set-url" [
remote: string@"nu-complete git remotes" # remote to set URL for
url: string # new URL for remote
]
# Show changes between commits, working tree etc
export extern "git diff" [
rev1_or_file?: string@"nu-complete git files-or-refs"
rev2?: string@"nu-complete git refs"
--cached # show staged changes
--name-only # only show names of changed files
--name-status # show changed files and kind of change
--no-color # disable color output
]
# Commit changes
export extern "git commit" [
--all(-a) # automatically stage all modified and deleted files
--amend # amend the previous commit rather than adding a new one
--message(-m) # specify the commit message rather than opening an editor
--no-edit # don't edit the commit message (useful with --amend)
]
# List commits
export extern "git log" [
# Ideally we'd allow completion of revisions here, but that would make completion of filenames not work.
-U # show diffs
--follow # show history beyond renames (single file only)
--grep: string # show log entries matching supplied regular expression
]
# Show or change the reflog
export extern "git reflog" [
]
# Stage files
export extern "git add" [
...file: string@"nu-complete git add" # file to add
--all(-A) # add all files
--dry-run(-n) # don't actually add the file(s), just show if they exist and/or will be ignored
--edit(-e) # open the diff vs. the index in an editor and let the user edit it
--force(-f) # allow adding otherwise ignored files
--interactive(-i) # add modified contents in the working tree interactively to the index
--patch(-p) # interactively choose hunks to stage
--verbose(-v) # be verbose
]
# Delete file from the working tree and the index
export extern "git rm" [
-r # recursive
--force(-f) # override the up-to-date check
--dry-run(-n) # Don't actually remove any file(s)
--cached # unstage and remove paths only from the index
]
# Show the working tree status
export extern "git status" [
--verbose(-v) # be verbose
--short(-s) # show status concisely
--branch(-b) # show branch information
--show-stash # show stash information
]
# Stash changes for later
export extern "git stash push" [
--patch(-p) # interactively choose hunks to stash
]
# Unstash previously stashed changes
export extern "git stash pop" [
stash?: string@"nu-complete git stash-list" # stash to pop
--index(-i) # try to reinstate not only the working tree's changes, but also the index's ones
]
# List stashed changes
export extern "git stash list" [
]
# Show a stashed change
export extern "git stash show" [
stash?: string@"nu-complete git stash-list"
-U # show diff
]
# Drop a stashed change
export extern "git stash drop" [
stash?: string@"nu-complete git stash-list"
]
# Create a new git repository
export extern "git init" [
--initial-branch(-b) # initial branch name
]
# List or manipulate tags
export extern "git tag" [
--delete(-d): string@"nu-complete git tags" # delete a tag
]
# Prune all unreachable objects
export extern "git prune" [
--dry-run(-n) # dry run
--expire: string # expire objects older than
--progress # show progress
--verbose(-v) # report all removed objects
]
# Start a binary search to find the commit that introduced a bug
export extern "git bisect start" [
bad?: string # a commit that has the bug
good?: string # a commit that doesn't have the bug
]
# Mark the current (or specified) revision as bad
export extern "git bisect bad" [
]
# Mark the current (or specified) revision as good
export extern "git bisect good" [
]
# Skip the current (or specified) revision
export extern "git bisect skip" [
]
# End bisection
export extern "git bisect reset" [
]
# Show help for a git subcommand
export extern "git help" [
command: string@"nu-complete git subcommands" # subcommand to show help for
]

@ -0,0 +1,28 @@
def "nu-complete npm" [] {
^npm -l
|lines
|find 'Run "'
|str trim
|split column -c ' '
|get column4
|str replace '"' ''
}
export extern "npm" [
command?: string@"nu-complete npm"
]
def "nu-complete npm run" [] {
open ./package.json
|get scripts
|columns
}
export extern "npm run" [
command?: string@"nu-complete npm run"
--workspace(-w)
--include-workspace-root
--if-present
--ignore-scripts
--script-shell
]

@ -0,0 +1,228 @@
def "nu-complete subcommands" [] {
^zellij --help | split column "SUBCOMMANDS:" | get column2.0 | str trim | lines | str trim | parse -r '(?P<command>^[
a-z-]+)' | get command
}
def "nu-complete zellij" [] {
[
{ value: "action", description: "Send actions to a specific session [aliases: ac]" },
{ value: "attach", description: "Attach to a session [aliases: a]" },
{ value: "convert-config", description: "" },
{ value: "convert-layout", description: "" },
{ value: "convert-theme", description: "" },
{ value: "edit", description: "Edit file with default $EDITOR / $VISUAL [aliases: e]" },
{ value: "help", description: "Print this message or the help of the given subcommand(s)" },
{ value: "kill-all-sessions", description: "Kill all sessions [aliases: ka]" },
{ value: "kill-session", description: "Kill the specific session [aliases: k]" },
{ value: "list-sessions", description: "List active sessions [aliases: ls]" },
{ value: "options", description: "Change behaviour of zellij" },
{ value: "run", description: "Run a command in a new pane [aliases: r]" },
{ value: "setup", description: "Setup zellij and check its configuration" },
# Aliases
{ value: "ac", description: "Alias for `action`" },
{ value: "a", description: "Alias for `attach`" },
{ value: "e", description: "Alias for `edit`" },
{ value: "ka", description: "Alias for `kill-all-sessions`" },
{ value: "k", description: "Alias for `kill-session`" },
{ value: "ls", description: "Alias for `list-sessions`" },
{ value: "r", description: "Alias for `run`" },
]
}
def "nu-complete zellij action" [] {
[
{ value: "close-pane", description: "Close the focused pane" },
{ value: "close-tab", description: "Close the current tab" },
{ value: "dump-screen", description: "Dump the focused pane to a file" },
{ value: "edit", description: "Open the specified file in a new zellij pane with your default EDITOR" },
{ value: "edit-scrollback", description: "Open the pane scrollback in your default editor" },
{ value: "focus-next-pane", description: "Change focus to the next pane" },
{ value: "focus-previous-pane", description: "Change focus to the precvious pane" },
{ value: "go-to-next-tab", description: "Go to the next tab" },
{ value: "go-to-previous-tab", description: "Go to the previous tab" },
{ value: "go-to-tab", description: "Go to tab with index [index]" },
{ value: "half-page-scroll-down", description: "Scroll down half page in focus pane" },
{ value: "half-page-scroll-up", description: "Scroll up half page in focus pane" },
{ value: "help", description: "Print this message or the help of the given subcommand(s)" },
{ value: "move-focus", description: "Move the focused pane in the specified direction. [right|left|up|down]" },
{ value: "move-focus-or-tab", description: "Move focus to the pane or tab (if on screen edge) in the specified direction. [right|left|up|down]" },
{ value: "move-pane", description: "Change the location of the focused pane in the specified direction. [right|left|up|down]" },
{ value: "new-pane", description: "Open a new pane in the specified direction. [right|down] If no direction specified, will try to use the biggest available space" },
{ value: "new-tab", description: "Create a new tab, optionally with a specified tab layout and name" },
{ value: "page-scroll-down", description: "Scroll down one page in focus pane" },
{ value: "page-scroll-up", description: "Scroll up one page in focus pane" },
{ value: "rename-pane", description: "Renames the focused pane" },
{ value: "rename-tab", description: "Renames the focused tab" },
{ value: "resize", description: "Resize the focused pane in the specified direction. [right|left|up|down|+|-]" },
{ value: "scroll-down", description: "Scroll down to the bottom in focus pane" },
{ value: "scroll-up", description: "Scroll up in the focused pane" },
{ value: "switch-mode", description: "Switch input mode of all connected clients [locked|pane|tab|resize|move|search|session]" },
{ value: "toggle-active-sync-tab", description: "Toggle between sending text commands to all panes on the current tab and normal mode" },
{ value: "toggle-floating-panes", description: "Toggle visibility of all floating panes in the current tab, open one if none exist" },
{ value: "toggle-fullscreen", description: "Toggle between fullscreen focus pane and normal layout" },
{ value: "toggle-pane-embed-or-floating", description: "Embed focused pane if floating or float focused pane if embedded" },
{ value: "toggle-pane-frames", description: "Toggle frames around panes in the UI" },
{ value: "undo-rename-pane", description: "Remove a previously set pane name" },
{ value: "undo-rename-tab", description: "Remove a previously set tab name" },
{ value: "write", description: "Write bytes to the terminal" },
{ value: "write-chars", description: "Write characters to the terminal" },
]
}
def "nu-complete zellij attach" [] {
[
{ value: "help", description: "Print this message or the help of a given subcommand(s)" },
{ value: "options", description: "Change the behaviour of zellij" },
]
}
def "nu-complete sessions" [] {
^zellij ls -n | lines | parse "{value} {description}"
}
# Turned off since it messes with sub-commands
#export extern "zellij" [
# command?: string@"nu-complete zellij"
# --config(-c) # <CONFIG> Change where zellij looks for the configuration file [env: ZELLIJ_CONFIG_FILE=]
# --config-dir # <CONFIG_DIR> Change where zellij looks for the configuration directory [env: ZELLIJ_CONFIG_DIR=]
# --debug(-d) # Specify emitting additional debug information
# --data-dir # <DATA_DIR> Change where zellij looks for plugins
# --help(-h) # Print help message
# --layout(-l) # <LAYOUT> Name of a predefined layout inside the layout directory or the path to a layout file
# --max-panes # <MAX_PANES> Maximum panes on screen, caution: opening more panes will close old ones
# --sessions(-s) # <SESSION> Specify name of a new session
# --version(-v) # Print version information
#]
# Send actions to a specific session
export extern "zellij action" [
command: string@"nu-complete zellij action"
--help(-h) # Print help information
]
# Renames the focused tab
export extern "zellij action rename-tab" [
name: string # Name for the tab
]
# Attach to a session
export extern "zellij attach" [
session_name: string@"nu-complete sessions" # Name of the session to attach to
command?: string@"nu-complete zellij attach"
--create(-c) # Create a session if one does not exist
--help(-h) # Print help information
--index # <INDEX> Number of the session index in the active sessions ordered by creation date
]
# <OLD_CONFIG_FILE>
export extern "zellij convert-config" [
file: path
--help(-h) # Print help information
]
# <OLD_LAYOUT_FILE>
export extern "zellij convert-layout" [
file: path
--help(-h) # Print help information
]
# <OLD_THEME_FILE>
export extern "zellij convert-theme" [
file: path
--help(-h) # Print help information
]
def "nu-complete directions" [] {
[ "right" "left" "down" "up" ]
}
# Edit file with default $EDITOR / $VISUAL
export extern "zellij edit" [
file: path
--cwd: path # <CWD> Change the working directory of the editor
--direction(-d): string@"nu-complete directions" # <DIRECTION> Direction to open the new pane in
--floating(-f) # Open the new pane in floating mode
--help(-h) # Print help information
--line-number(-l): number # <LINE_NUMBER> Open the file in the specified line number
]
# Print this message or the help of the given subcommand(s)
export extern "zellij help" [
command?: string@"nu-complete subcommands"
]
# Kill all sessions
export extern "zellij kill-all-sessions" [
--help(-h) # Print help information
--yes(-y) # Automatic yes to prompts
]
# Kill the specific session
export extern "zellij kill-session" [
session_name: string@"nu-complete sessions" # <TARGET_SESSION> Name of target session
--help(-h) # Print help information # Print help information
]
# List active sessions
export extern "zellij list-sessions" [
--help(-h) # Print help information
]
def "nu-complete string bools" [] {
[ "'true'" "'false'" ]
}
def "nu-complete option copy-clipboard" [] {
[ "system", "primary" ]
}
def "nu-complete option on-force-close" [] {
[ "quit" "detach" ]
}
# Change the behaviour of zellij
export extern "zellij options" [
--attach-to-session: string@"nu-complete string bools" # Whether to attach to a session specified in "session-name" if it exists [possible values: true, false]
--copy-clipboard: string@"nu-complete option copy-clipboard" # OSC52 destination clipboard [possible values: system, primary]
--copy-command: string # <COPY_COMMAND> Switch to using a user supplied command for clipboard instead of OSC52
--copy-on-select: string@"nu-complete string bools" # Automatically copy when selecting text (tru or false) [possible values: true, false]
--default-layout # <DEFAULT_LAYOUT> Set the default layout
--default-mode # <DEFAULT_MODE> Set the default mode
--default-shell # <DEFAULT_SHELL> Set the default shell
--disable-mouse-mode # Disable handling of mouse events
--help(-h) # Print help information
--layout-dir: path # <LAYOUT_DIR> Set the layout_dir, defaults to subdirectory of config dir
--mirror-session: string@"nu-complete string bools" # Mirror session when multiple users are connected (true or false) [possible values: true, false]
--mouse-mode: string@"nu-complete string bools" # <MOUSE_MODE> Set the handling of mouse events (true or false) Can be temporarily bypassed by the [SHIFT] key [possible values: true, false]
--on-force-close: string@"nu-complete option on-force-close" # <ON_FORCE_CLOSE> Set behaviour on force close (quit or detach)
--pane-frames: string@"nu-complete string bools" # <PANE_FRAMES> Set display of pane frames (true or false) [possible values: true, false]
--scroll-buffer-size: any # <SCROLL_BUFFER_SIZE>
--scrollback-editor: path # <SCROLLBACK_EDITOR> Explicit full path to open the scrollback editor (default is $EDITOR or $VISUAL)
--session-name: string # <SESSION_NAME> The name of the session to create when starting Zellij
--simplified-ui: string@"nu-complete string bools" # <SIMPLIFIED_UI> Allow plugins to use a more simplified layout that is compatible with more fonts (true or false) [possible values: true, false]
--theme: string # <THEME> Set the default theme
--theme-dir: path # <THEME_DIR> Set the theme_dir, defaults to subdirectory of config dir
]
# Run a command in a new pane
export extern "zellij run" [
command: string # Command to run
--close-on-exit(-c) # Close the pane immediately when its command exits
--cwd: path # <CWD> Change the working directory of th new pane
--direction(-d): string@"nu-complete directions" # <DIRECTION> Direction to open new pane in
--floating(-f) # Open the new pane in floating mode
--help(-h) # Print help information
--name(-n): string # <NAME> Name of the new pane
--start-suspended(-s) # Start the command suspended, only running after you first presses ENTER
]
export extern "zellij setup" [
--check # Checks the configuration of zellij and displays currently used directories
--clean # Disables loading of configuration file at default location, loads the defaults that zellij ships with
--dump-config # Dump the default configuration file to stdout
--dump-layout: string # <DUMP_LAYOUT> Dump the specified layout file to stdout
--generate-auto-start: string # Generates auto-start for the specified shell
--generate-completion: string # Generates completion for the specified shell
--help(-h) # Print help information
]

@ -45,12 +45,17 @@ export def floating-prompt [] {
}
export def last-notification [] {
let notifications = (open $env.NOTIFY_FILE | lines)
if ($notifications | is-empty) {
return
$env.NTFY_CHKSUM = (shasum $env.NOTIFY_FILE)
if not (task group exists "notify") {
task group add notify -p 4
}
task spawn -d 5sec -g notify {
if (shasum $env.NOTIFY_FILE) == $env.NTFY_CHKSUM {
"" | save -f $env.NOTIFY_FILE
}
}
$notifications | skip 1 | save -f $env.NOTIFY_FILE
$notifications | first
open $env.NOTIFY_FILE | str trim
}
def open-editor [path: string] {
@ -109,7 +114,7 @@ def --env create-notify-send [tmpdir: string, tmpbin: string] {
let new_ntfy = ($tmpbin | path join "notify-send")
("#!/bin/env nu
def main [title: string, content: string] {
$\"(ansi {attr: bi})($title)(ansi reset) ($content)\\n\" | save -a $env.NOTIFY_FILE
$\"(ansi {attr: bi})($title)(ansi reset) ($content)\\n\" | save -f $env.NOTIFY_FILE
}
" | save -f $new_ntfy)
chmod +x $new_ntfy

@ -432,3 +432,7 @@ export def set-parallel-limit [
pueue parallel ...$args $max
}
export def `group exists` [name: string] {
$name in ...(group | columns)
}

@ -18,7 +18,7 @@ config:needs("nu", "nushell")
config:needs("systemctl", "systemd")
config:needs("wezterm", "wezterm")
config:needs("zellij", "zellij")
config:needs("starship", "starship")
config:needs("starship", "starship.toml")
config:needs("lvim", "lvim")
config:needs("lvim", "lvim")
config:needs("git", "nushell/scripts/git.nu")
@ -26,4 +26,6 @@ config:needs("pueue", "pueue")
config:needs("pueue", "nushell/scripts/task.nu")
config:needs("pueue", "systemd/user/pueued.service")
config:needs("npm", "nushell/completions/npm-completions.nu")
return config

@ -43,7 +43,7 @@ layout {
command_notify_command "nu -c \"use ide.nu; ide last-notification\""
command_notify_format "{stdout}"
command_notify_interval "5"
command_notify_interval "1"
command_notify_rendermode "static"
datetime "#[fg=#181825,bg=#b1bbfa] {format} "

Loading…
Cancel
Save