GithubHelp home page GithubHelp logo

dnnr / fish-async-prompt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acomagu/fish-async-prompt

0.0 1.0 0.0 27.06 MB

Make your prompt asynchronous to improve the reactivity.

License: MIT License

Shell 100.00%

fish-async-prompt's Introduction

fish-async-prompt

Make your prompt asynchronous in Fish.

Description

Demo Video

We run your fish_prompt and fish_right_prompt functions as a separate process to update your prompt asynchronously.

Installation

With Fisher:

$ fisher install acomagu/fish-async-prompt

Loading Indicator

By default, it prints the previous prompt until the new one is ready. But you can change it to any other string. Define a function which named <prompt-func-name>_loading_indicator, like fish_prompt_loading_indicator.

For example, to show as the indicator of right prompt:

function fish_right_prompt_loading_indicator
    echo (set_color '#aaa')''(set_color normal)
end

demo1

You can also use the previous prompt string because the function receives it as the first argument. For example, show previous prompt but grayed out:

function fish_right_prompt_loading_indicator -a last_prompt
    echo -n "$last_prompt" | sed -r 's/\x1B\[[0-9;]*[JKmsu]//g' | read -zl uncolored_last_prompt
    echo -n (set_color brblack)"$uncolored_last_prompt"(set_color normal)
end

demo2

The loading indicator can be set up not only for fish_prompt or fish_right_prompt, but also for other function, if you specify it in async_prompt_functions. e.g.

function _git_branch_name
    sleep 1 # For demo.
    git symbolic-ref --short HEAD ^/dev/null
end

function fish_right_prompt
    echo (set_color 88f)(_git_branch_name) (set_color cyan)(prompt_pwd)
end

# Async prompt setup.
set async_prompt_functions _git_branch_name

function _git_branch_name_loading_indicator
    echo (set_color brblack)…(set_color normal)
end

demo3

Other Configurations

If you have problems, try changing the values of these variables. When you change the configurations, please restart your shell.

async_prompt_inherit_variables

Define variables inherited to prompt functions. Set all to pass all global variables.

Default: status pipestatus SHLVL CMD_DURATION fish_bind_mode

Example:

set -U async_prompt_inherit_variables all

async_prompt_functions

Define functions replaced to run asynchronously. Usually one or both of fish_prompt and fish_right_prompt.

Other functions can be specified, but they must be called from fish_prompt or fish_right_prompt and function arguments can't be passed to it.

Default: fish_prompt fish_right_prompt

Example:

set -U async_prompt_functions fish_right_prompt

async_prompt_internal_signal

fish-async-prompt uses SIGUSR1 to communicate with the spawned process by default. If it conflicts with other plugin/program, try changing this.

Default: SIGUSR1

Example:

set -U async_prompt_internal_signal SIGUSR2

Author

License

MIT

fish-async-prompt's People

Contributors

acomagu avatar alexbeggs avatar alyyousuf7 avatar amok avatar arobase-che avatar delphinus avatar ilancosman avatar jorgebucaran avatar kidonng avatar mec07 avatar metiulekm avatar miki725 avatar notwearingpants avatar soraxas avatar

Watchers

 avatar

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.