script
starship
script | starship | |
---|---|---|
1 | 299 | |
46 | 41,224 | |
- | 2.6% | |
0.0 | 9.7 | |
over 1 year ago | 2 days ago | |
PowerShell | Rust | |
- | ISC License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
script
-
What’s so special about PS1? Fun with customizing Bash command prompts
warp_escape_ps1 () { tr '\n\n' ' ' <<< "$*" | xxd -p | tr -d '\n' } # Format a string value according to JSON syntax - Adapted from https://github.com/lework/script. warp_escape_json () { # Explanation of the sed replacements (each command is separated by a `;`): # s/(["\\])/\\\1/g - Replace all double-quote (") and backslash (\) characters with the escaped versions (\" and \\) # s/\b/\\b/g - Replace all backspace characters with \b # s/\t/\\t/g - Replace all tab characters with \t # s/\f/\\f/g - Replace all form feed characters with \f # s/\r/\\r/g - Replace all carriage return characters with \r # $!s/$/\\n/ - On every line except the last, insert the \n escape at the end of the line # Note: sed acts line-by-line, so it doesn't see the literal newline characters to replace # # tr -d '\n' - Remove the literal newlines from the final output # # Additional note: In a shell script between single quotes ('), no escape sequences are interpreted. # To work around that and insert the literal values into the regular expressions, we stop the single-quote, # then add the literal using ANSI-C syntax ($'\t'), then start a new single-quote. That is the meaning # behind the various `'$'\b''` blocks in the command. All of these separate strings are then concatenated # together to form the full argument to send to sed. sed -E 's/(["\\])/\\\1/g; s/'$'\b''/\\b/g; s/'$'\t''/\\t/g; s/'$'\f''/\\f/g; s/'$'\r''/\\r/g; $!s/$/\\n/' <<<"$*" | tr -d '\n' } warp_precmd () { # $? is relative to the process so we MUST check this first # or else the exit code will correspond to the commands # executed within this block instead of the actual last # command that was run. local exit_code=$? # Clear the prompt again before the command is rendered as it could # have been reset by the user's bashrc or by setting the variable # on the command line. if [[ -n $PS1 ]]; then WARP_PS1="$PS1" fi unset PS1 unset PROMPT # Escaped PS1 variable local escaped_ps1 if [[ $WARP_FEATURE_FLAG_HONOR_PS1 == "1" ]]; then # Tricking the shell into rendering the prompt # Note that in more modern versions of bash we could use ${PS1@P} to achieve the same, # but macOs comes by default with a much older version of bash, and we want to be compatible. deref_ps1=$(echo -e "\n" | PS1="$WARP_PS1" bash --norc -i 2>&1 | head -2 | tail -1) escaped_ps1=$(warp_escape_ps1 "$(echo "$deref_ps1")") fi # Flush history history -a # Reset the custom kill-whole-line binding as the user's bashrc (which is sourced after bashrc_warp) # could have added another bind. This won't have any user-impact because these shortcuts are only run # in the context of the bash editor, which isn't displayed in Warp. bind -r '"\C-p"' bind "\C-p":kill-whole-line local escaped_pwd escaped_pwd=$(warp_escape_json "$PWD") local escaped_virtual_env="" if [ ! -z "$VIRTUAL_ENV" ]; then escaped_virtual_env=$(warp_escape_json "$VIRTUAL_ENV") fi local escaped_conda_env="" if [ ! -z "$CONDA_DEFAULT_ENV" ]; then escaped_conda_env=$(warp_escape_json "$CONDA_DEFAULT_ENV") fi local git_branch git_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "") local escaped_git_branch escaped_git_branch=$(warp_escape_json "$git_branch") # At this point, escaped prompt looks something like # \\u{001B}\\u{005B}\\u{0030}\\u{0031}\\u{003B} ... # We need to maintain the double quoting of \\u in the message that # is sent otherwise the receiving side will interpret the value # as JS string literals of the form \uHEX, and will include # ctrl characters (like ESC) in the json, which will cause a JSON # parse error. # Note WARP_SESSION_ID doesn't need to be escaped since it's a number local escaped_json="{\"hook\": \"Precmd\", \"value\": {\"pwd\": \"$escaped_pwd\", \"ps1\": \"$escaped_ps1\", \"git_branch\": \"$escaped_git_branch\", \"virtual_env\": \"$escaped_virtual_env\", \"conda_env\": \"$escaped_conda_env\", \"exit_code\": $exit_code, \"session_id\": $WARP_SESSION_ID}}" warp_send_message "$escaped_json" }
starship
-
Tools that keep me productive
Starship - A cross shell prompt
-
Atuin – Magical Shell History
Agreed, I use this in conjunction with Starship [1], both initialized specifically for Fish in the config. I love this shell so much.
[1] - https://starship.rs/
- Starship.rs: minimal, fast prompt for any shell
- Starship: The minimal, fast, and customizable prompt
-
Oh My Zsh
starship is the new spaceship, yo
https://starship.rs/
- Starship: Minimal, fast, infinitely customizable prompt for any shell
-
Z – Jump Around
It seems like the Rust community is quite happy to support alternative shells. I’ve seen couple of projects, now, that support way more esoteric shells than I would expect, like ’xonsh’. Starship (https://starship.rs/) immediately comes to mind.
- MacOS tools to make your life easier
-
[MacOS] Setting up zsh in MacOS, any hints, dos/don'ts, advice, or guides?
Until now I have been using bash on Windows with Starship as the prompt. The only reason I went with Starship, is that it was easy to setup and at the time I did not have much free time to devout to the shell/prompt configuration.
-
Monaspace
I'm staying on BitstromWera Nerd Font. Works great with Starship.
https://www.nerdfonts.com/font-downloads
https://starship.rs
What are some alternatives?
ohmyzsh - 🙃 A delightful community-driven (with 2,300+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
oh-my-posh - The most customisable and low-latency cross platform/shell prompt renderer
spaceship-prompt - :rocket::star: Minimalistic, powerful and extremely customizable Zsh prompt
powerlevel10k - A Zsh theme
zsh-autocomplete - 🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
alacritty - A cross-platform, OpenGL terminal emulator.
fish-shell - The user-friendly command line shell.
powerline - Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile.
pure - Pretty, minimal and fast ZSH prompt
tide - 🌊 The ultimate Fish prompt.
zsh-autosuggestions - Fish-like autosuggestions for zsh