Skip to content

starship: skip one program invocation on each shell init#2862

Merged
berbiche merged 1 commit intonix-community:masterfrom
nagy:starship-init
Apr 7, 2022
Merged

starship: skip one program invocation on each shell init#2862
berbiche merged 1 commit intonix-community:masterfrom
nagy:starship-init

Conversation

@nagy
Copy link
Copy Markdown
Contributor

@nagy nagy commented Apr 4, 2022

Description

The code that is being evaled without the --print-full-init flag is this:

__main() {
    local major="${BASH_VERSINFO[0]}"
    local minor="${BASH_VERSINFO[1]}"

    if ((major > 4)) || { ((major == 4)) && ((minor >= 1)); }; then
        source <(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)
    else
        source /dev/stdin <<<"$(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)"
    fi
}
__main
unset -f __main

This code checks for bash version >= 4.1 , which has been released in 2009. Since this version is widely unavailable in nixpkgs, we can skip one program invocation and directly call starship init bash --print-full-init.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

    • Added myself and the module files to .github/CODEOWNERS.

The code that is being evaled without the `--print-full-init` flag is
this:

```sh
__main() {
    local major="${BASH_VERSINFO[0]}"
    local minor="${BASH_VERSINFO[1]}"

    if ((major > 4)) || { ((major == 4)) && ((minor >= 1)); }; then
        source <(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)
    else
        source /dev/stdin <<<"$(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)"
    fi
}
__main
unset -f __main
```

This code checks for bash version >= 4.1 , which has been released in
2009. Since this version is widely unavailable in nixpkgs, we can skip
one program invocation and directly call `starship init bash
--print-full-init`.
Copy link
Copy Markdown
Member

@berbiche berbiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

@berbiche berbiche merged commit 3071ea2 into nix-community:master Apr 7, 2022
@nagy nagy deleted the starship-init branch April 7, 2022 18:41
@teto teto mentioned this pull request Aug 22, 2022
7 tasks
teto pushed a commit to teto/home-manager that referenced this pull request Aug 22, 2022
…ty#2862)

The code that is being evaled without the `--print-full-init` flag is
this:

```sh
__main() {
    local major="${BASH_VERSINFO[0]}"
    local minor="${BASH_VERSINFO[1]}"

    if ((major > 4)) || { ((major == 4)) && ((minor >= 1)); }; then
        source <(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)
    else
        source /dev/stdin <<<"$(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)"
    fi
}
__main
unset -f __main
```

This code checks for bash version >= 4.1 , which has been released in
2009. Since this version is widely unavailable in nixpkgs, we can skip
one program invocation and directly call `starship init bash
--print-full-init`.
spacekookie pushed a commit to spacekookie/home-manager that referenced this pull request Feb 10, 2023
…ty#2862)

The code that is being evaled without the `--print-full-init` flag is
this:

```sh
__main() {
    local major="${BASH_VERSINFO[0]}"
    local minor="${BASH_VERSINFO[1]}"

    if ((major > 4)) || { ((major == 4)) && ((minor >= 1)); }; then
        source <(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)
    else
        source /dev/stdin <<<"$(/nix/store/...-starship-1.3.0/bin/starship init bash --print-full-init)"
    fi
}
__main
unset -f __main
```

This code checks for bash version >= 4.1 , which has been released in
2009. Since this version is widely unavailable in nixpkgs, we can skip
one program invocation and directly call `starship init bash
--print-full-init`.
anka-213 added a commit to anka-213/home-manager that referenced this pull request Feb 7, 2026
Same fix as nix-community#2862, but for fish and ion.

Both of the shell's indirect init functions do exactly what we do here already.
nagy added a commit to nagy/nixpkgs that referenced this pull request Feb 15, 2026
The code that is being evaled without the `--print-full-init` flag is
this:

```
eval -- "$(/nix/store/...-starship-1.24.2/bin/starship init bash --print-full-init)"
```

We can skip one program invocation and directly call `starship init
bash --print-full-init`.

This is a replication of my other PR in home-manager:

- nix-community/home-manager#2862
dbeley pushed a commit to dbeley/nixpkgs that referenced this pull request Feb 16, 2026
The code that is being evaled without the `--print-full-init` flag is
this:

```
eval -- "$(/nix/store/...-starship-1.24.2/bin/starship init bash --print-full-init)"
```

We can skip one program invocation and directly call `starship init
bash --print-full-init`.

This is a replication of my other PR in home-manager:

- nix-community/home-manager#2862
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants