Code Monkey home page Code Monkey logo

spacezsh-prompt's Introduction


Spacezsh ๐Ÿš€โญ

ZSH prompt for Astronauts.

Zsh Version MIT license

Built with โค๏ธŽ by laggardkernel and contributors
A fork of Spaceship ZSH by Denys Dovhan

Spacezsh is an async prompt tries to do things right in the ZSH way. It introduces a lot of ZSH goodies including:

  • Conditional async on each section/segment with tag section::async
  • 100% promptinit compliant.
  • autoload all of the functions.
  • Speed the prompt up with ZSH built-in utilities
    • Env var $EPOCHREALTIME replaces external command date in exec_time section;
    • ZSH module jobstates replaces external command jobs in jobs section;
    • Section vcs based on ZSH utility vcs_info replaces section git and hg. It also adds support for SVN;
    • Complete vi mode with more type of hooks being used for a better detection of mode changes.
    • Trigger prompt redrawing on hook chpwd where hook precmd is not triggered;
  • For more changes, new features, new sections brought by Spacezsh, check the CHANGELOG for detail.

Spacezsh with Hyper and One Dark

Visit Troubleshooting for instructions to recreate this terminal setup.

Features

  • Clever hostname and username displaying.
  • Prompt character turns red if the last command exits with non-zero code.
  • (New) Prompt character changes with vi modes.
  • (New) Current branch and status support for Git, Mercurial, SVN:
    • ? โ€” untracked changes;
    • โ—Œ โ€” unstaged changes;
    • โ— โ€” staged/uncommitted changes in the index;
    • $ โ€” stashed changes;
    • โ‡ก โ€” ahead of remote branch;
    • โ‡ฃ โ€” behind of remote branch;
    • The following states are supported but disable by default:
      • ยป โ€” renamed files;
      • โœ˜ โ€” deleted files;
      • = โ€” unmerged changes;
      • changeset/commit id;
  • Indicator for jobs in the background (โœฆ).
  • Current Node.js version, through nvm/nodenv/n (โฌข).
  • Current Ruby version, through rvm/rbenv/chruby/asdf (๐Ÿ’Ž).
  • Current Elm version (๐ŸŒณ)
  • Current Elixir version, through kiex/exenv/elixir (๐Ÿ’ง).
  • Current Swift version, through swiftenv (๐Ÿฆ).
  • Current Xcode version, through xenv (๐Ÿ› ).
  • Current Go version (๐Ÿน).
  • Current PHP version (๐Ÿ˜).
  • Current Rust version (๐—ฅ).
  • Current version of Haskell GHC Compiler, defined in stack.yaml file (ฮป).
  • Current Julia version (เฎƒ).
  • (New) Currnet Vagrant machine status (๏ผถ)
  • Current Docker version and connected machine (๐Ÿณ).
  • Current Amazon Web Services (AWS) profile (โ˜๏ธ) (Using named profiles).
  • Current Google Cloud Platform gcloud active configuration (โ˜๏ธ).
  • Current Python virtualenv (๐Ÿ).
  • Current .NET SDK version, through dotnet-cli (.NET).
  • Current Ember.js version, through ember-cli (๐Ÿน).
  • Current Kubectl context (โ˜ธ๏ธ).
  • Current Terraform workspace (๐Ÿ› ).
  • Package version, if there's is a package in current directory (๐Ÿ“ฆ).
  • Current battery level and status:
    • โ‡ก - charging;
    • โ‡ฃ - discharging;
    • โ€ข - fully charged.
  • Current Vi-mode mode (with handy aliases for temporarily enabling).
  • Optional exit-code of last command (how to enable).
  • Optional time stamps 12/24hr in format (how to enable).
  • Execution time of the last command if it exceeds the set threshold.

Want more features? Please, open an issue or send pull request.

Requirements

To work correctly, you will first need:

Installing

Use this command in your .zshrc to load Spacezsh:

# Optional: compile source files into bytecode to speed up init
# zinit ice pick'spacezsh.zsh' \
#   compile'{presets/^(*.zwc),lib/**/^(*.zwc),sections/^(*.zwc)}'
zinit light laggardkernel/spacezsh-prompt

TODO

Clone this repo:

git clone https://github.com/laggardkernel/spacezsh-prompt.git "$ZSH_CUSTOM/themes/spacezsh-prompt" --depth=1

Symlink spacezsh.zsh-theme to your oh-my-zsh custom themes directory:

ln -s "$ZSH_CUSTOM/themes/spacezsh-prompt/spacezsh.zsh-theme" "$ZSH_CUSTOM/themes/spacezsh.zsh-theme"

Set ZSH_THEME="spacezsh" in your .zshrc.

Customization

Spacezsh works well out of the box, but you can customize almost everything if you want.

  • Options โ€” Tweak section's behavior with tons of options.
  • API โ€” Define a custom section that will do exactly what you want.

You have the ability to customize or disable specific elements of Spaceship. Set options and define new sections in your .zshrc file, after the theme. To include a custom section you have defined in your prompt, add it to the SPACESHIP_PROMPT_ORDER.

For example:

# .zshrc

# add Spaceship (differs by setup, see Installating above)

section_mysection() {
  # ...
}

SPACESHIP_PROMPT_ORDER=(<any preceding sections> mysection <any following sections>)

To append custom sections to the default Spaceship prompt, follow the form:

SPACESHIP_PROMPT_ORDER=($SPACESHIP_PROMPT_ORDER mysection)

To prepend custom sections to the default Spaceship prompt, follow the form:

SPACESHIP_PROMPT_ORDER=(mysection $SPACESHIP_PROMPT_ORDER)

Troubleshooting

Having trouble? Take a look at out Troubleshooting page.

Still struggling? Please, file an issue, describe your problem and we will gladly help you.

Credits

License

MIT ยฉ laggardkernel

spacezsh-prompt's People

Contributors

abnersajr avatar arttse avatar asonix avatar bleys avatar bric3 avatar denysdovhan avatar el7cosmos avatar gillchristian avatar gurpreetatwal avatar igorcoding avatar krismichalski avatar kulkarnih avatar laggardkernel avatar lautis avatar mawburn avatar maximbaz avatar memoryonrepeat avatar nelsonghezzi avatar nfischer avatar nomaed avatar poissonballon avatar rolfkoenders avatar rteabeault avatar runrioter avatar salmanulfarzy avatar segevfiner avatar shihanng avatar snuggle avatar tesla809 avatar thebluejay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spacezsh-prompt's Issues

Some jobs are not done when too many sections are run async in the worker

Current behavior

When too many sections are enable with ::async, some of them failed to be rendered and placeholder โ€ฆ is displayed. Seems some of the jobs are not done in the worker.

Need to dig it deeper when I have spare time.

Environment

Spaceship version: v4.5.0-8-g9ecf72b
Zsh version: zsh 5.8 (x86_64-apple-darwin18.7.0)
Zsh plugin manager: zinit
Terminal emulator: iTerm + tmux
Operating system: macOS 10.14.6

SPACESHIP_PROMPT_SUFFIXES_SHOW doesn't work

SPACESHIP_PROMPT_SUFFIXES_SHOW is changed in function sz::section. While this function is executed by the async worker now, so it's only changed in the pseudo tty but not the normal shell started by the user.

Put it in another way, the change is not synced back to the shell you are running.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.