Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Starship: Cross-shell prompt written in Rust (starship.rs)
48 points by cercatrova on Dec 6, 2021 | hide | past | favorite | 7 comments


I love starship. Compiled binary, so it's extremely fast. I've tried a number of alternative prompt approaches in the past, but they've almost all been script based approaches, and the delay as the prompt message was generated was always palpable to me. Starship has been the only one I've stuck with, primarily because of just how fast it is.


It also has nice defaults and looks great without a single line of configuration.


Since I was trying out nushell, I came across Starthip which supports nushell! I noticed that prompt managers which run non-shell binaries may be unable to support things like showing the tty since I assume they are execing any external tools (/usr/bin/tty) in a non-tty environment. But still very cool to have the same prompt run unmodified in zsh, bash, nushell etc. The git VCS performance in it is pretty good too even in large monorepos.


On linux (and I think even osx), even when stdin, stdout, and stderr are redirected, you can always get at the current session's tty via "/dev/tty" unless the executing program spawns a new session which would be very unlikely in this case. This is why things like sudo can defeat pipes and prompt you.


Oh, you are right! This works by looking at /proc/$ppid/fd/1

    format = """$all\
    ${custom.tty}"""

    [custom.tty]
    description = "tty"
    when = 'true'
    command = """
    tpid=$(ps -o pid= -p "$(($(ps -o sid= -p "$$")))")
    tpid=$(( tpid + 0 ))
    readlink /proc/$tpid/fd/1 | sed -e 's|/dev/||'
    """
    format = ' [$output]($style)'
    shell = ["bash", "--noprofile", "--norc"]
    style = 'blue'


fish + starship has been my setup for a while now and it's super pleasant because it pretty much does all I want out of the box


tcsh+starship is a pretty nice combination.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: