All Projects → denysdovhan → Robbyrussell Node

denysdovhan / Robbyrussell Node

Licence: mit
Cross-shell robbyrussell theme written in JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Labels

Projects that are alternatives of or similar to Robbyrussell Node

Prompts
❯ Lightweight, beautiful and user-friendly interactive prompts
Stars: ✭ 6,970 (+6940.4%)
Mutual labels:  prompt
Pretty Git Prompt
`git status` inside your shell prompt
Stars: ✭ 43 (-56.57%)
Mutual labels:  prompt
Ng Popups
🎉 Alert, confirm and prompt dialogs for Angular. Simple as that.
Stars: ✭ 80 (-19.19%)
Mutual labels:  prompt
Inquirer Checkbox Plus Prompt
Checkbox with autocomplete and other additions for Inquirer
Stars: ✭ 25 (-74.75%)
Mutual labels:  prompt
React Notie
Simple notifications for react
Stars: ✭ 27 (-72.73%)
Mutual labels:  prompt
Clc
Tiny bash utility for coloring terminal output and prompt
Stars: ✭ 58 (-41.41%)
Mutual labels:  prompt
Geometry
geometry is a minimal, fully customizable and composable zsh prompt theme
Stars: ✭ 770 (+677.78%)
Mutual labels:  prompt
Windows10debloater
Script to remove Windows 10 bloatware.
Stars: ✭ 11,462 (+11477.78%)
Mutual labels:  prompt
Jquery Alertable
Minimal alert and confirmation alternatives.
Stars: ✭ 38 (-61.62%)
Mutual labels:  prompt
Tty Prompt
A beautiful and powerful interactive command line prompt
Stars: ✭ 1,210 (+1122.22%)
Mutual labels:  prompt
Prompt Password
This repository has been archived, use the built-in password prompt in Enquirer instead.
Stars: ✭ 8 (-91.92%)
Mutual labels:  prompt
Prompt Checkbox
This repository has been archived, use Enquirer instead.
Stars: ✭ 21 (-78.79%)
Mutual labels:  prompt
Angel Ps1
Your fancy shell prompt fed by your guardian angel
Stars: ✭ 60 (-39.39%)
Mutual labels:  prompt
Dotfiles
Configurations for the tools I use every day
Stars: ✭ 898 (+807.07%)
Mutual labels:  prompt
Alertjs
Dialog Builder allows you to create fully customisable dialogs and popups in Dynamics 365.
Stars: ✭ 80 (-19.19%)
Mutual labels:  prompt
Powerline Extra Symbols
▶️ Extra glyphs for your powerline separators
Stars: ✭ 778 (+685.86%)
Mutual labels:  prompt
Termly.js
Simple, Extensible, Hackable and Lightweight Javascript Browser Terminal Simulator!
Stars: ✭ 56 (-43.43%)
Mutual labels:  prompt
Vue Simple Alert
Simple alert(), confirm(), prompt() for Vue.js
Stars: ✭ 93 (-6.06%)
Mutual labels:  prompt
Mimir
Fast and minimal shell prompt
Stars: ✭ 90 (-9.09%)
Mutual labels:  prompt
Smalltalk
Promise-based Alert, Confirm and Prompt replacement
Stars: ✭ 76 (-23.23%)
Mutual labels:  prompt

robbyrussell-img

robbyrussell-node

NPM version Node.js version Dependency status Build status Donate

Cross-shell robbyrussell theme written in JavaScript

Motivation

I'm developing 🚀⭐️ spaceship-zsh-theme which is an extremely powerful and customizable prompt for ZSH. It supports a lot of environments and tools to make you enjoy using it. However, there are plenty issues I faced: zsh is hard, dependency management is difficult, testing is near to impossible and so on.

This project is just a proof of concept. Definitely, that's not the best implementation, nevertheless, it opens interesting possibilities:

  • high-level language — ZSH is nice, but not for programming. JavaScript or Python seems more comfortable for these cases.
  • single code base — Single source code for all shells. The core logic is written in a high-level language while the shell-specific code is located in special files called adapters.
  • cross-shell — different shells are too specific. Single code base on high-level language with unified interface gives us an ability to use it with any shell(fish, zsh, bash, sh, etc).
  • cross-platform — things like pkg allows us to package prompt into binary and use it wherever we want, even without installed language runtime.
  • testable — high-level language and its infrastructure make it possible to test prompt components with tools like Mocha, Jest or tape (unlike traditional prompts which are usually untested).
  • dependency managementNPM, RubyGems and PyPI store thousands of packages that could be used for special prompt's needs. It's also possible to install prompt itself with one of these package managers.
  • asynchronous checks — the more synchronous checks you do, the slower prompt becomes. Things like async/await or Promise.all() could perform environment checks concurrently, so we can achieve significant performance improvement.

Why JavaScript? Just because it's a high-level language which provides wide infrastructure with a good package manager, lots of packages and good community. It's quite fast and easy to make a simple working example.

Installation

npm

npm install -g robbyrussell

Done. This command should source the corresponding adapter for your shell. Just reload your terminal.

Binaries

If you don't have Node.js installed on your machine, you can download pre-built binaries with built-in Node.js version.

⬇️ Download binary ⬇️

Use them in your shell configuration with adapters.

bash:

# BASH-specific adapter
robbyrussell_bash_adapter() {
  robbyrussell_previous_exit_code="$?"
  /path/to/robbyrussell $robbyrussell_previous_exit_code 'bash'
}

# set prompt
PS1='$(robbyrussell_bash_adapter)'

zsh:

# ZSH-specific adapter
robbyrussell_zsh_adapter() {
  robbyrussell_previous_exit_code="$?"
  /path/to/robbyrussell $robbyrussell_previous_exit_code 'zsh'
}

# set prompt
PROMPT='$(robbyrussell_zsh_adapter)'

fish:

# FISH-specific adapter
function robbyrussell_fish_adapter -d "a robbyrussell theme adapter for fish"
  set robbyrussell_previous_exit_code "$status"
  /path/to/robbyrussell $robbyrussell_previous_exit_code 'fish'
end

# set prompt
function fish_prompt
  # fish splits command substitutions on newlines
  # need to temporarily reset IFS to empty
  #   @see: http://stackoverflow.com/a/34186172/5508862
  set -l IFS
  robbyrussell_fish_adapter
end

Configuration

Exposing the pormpt settings as environment variables is a known problem. This prompt reads a special configuration file from your home directory, which allows you to define more complex configs. A prompt automatically looks for ~/.prompt-config.js or ~/.prompt-config.json files. These files should export configuration object.

Important: A prompt needs to escape colors codes, otherwise it would behave incorrectly. This prompt includes patched chalk package with escape codes for current process.env.SHELL.

Default config looks like this:

// Patched for current shell chalk/chalk colors
const styles = require('robbyrussell/utils/colors');

module.exports = {
  /**
   * Check git status asynchronously
   */
  async: false,
  /**
   * Prompt prefix and suffix
   */
  prompt: {
    open: styles.bold.open,
    close: styles.bold.close + styles.reset.close
  },
  /**
   * Status code
   */
  status: {
    char: '➜',
    success: styles.green.open,
    failure: styles.red.open,
  },
  /**
   * Directory style
   */
  dir: {
    color: styles.cyan.open
  },
  /**
   * Git status styles
   */
  git: {
    indicator: styles.blue.open,
    branch: styles.red.open,
    dirty: styles.yellow.open,
    dirtyChar: '✗'
  }
};

License

MIT © Denys Dovhan

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].