Giter Club home page Giter Club logo

fish-osc133's Introduction

fish-osc133

This plugin introduces OSC 133 escape sequences to your shell output to define input, output and prompt zones.

This is used by modern terminal emulators to provide functions such as folding, jumping, etc.

Installation

$ fisher install acomagu/fish-osc133

fish-osc133's People

Contributors

acomagu avatar jake-low avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

jake-low snptrs

fish-osc133's Issues

`$status` of last command is overwritten before `fish_prompt` runs

I use a prompt that's similar to this (taken from the fish docs):

function fish_prompt
    set -l last_status $status
    # Prompt status only if it's not 0
    set -l stat
    if test $last_status -ne 0
        set stat (set_color red)"[$last_status]"(set_color normal)
    end

    string join '' -- (set_color green) (prompt_pwd) (set_color normal) $stat '> '
end

The relevant bit is that before doing anything else, the prompt reads the $status variable which holds the return code of the last command, and saves it to a local variable $last_status. Then it goes about constructing the prompt string, running other commands which overwrite $status in the process. It uses $last_status to conditionally show a red error indicator in the prompt.

When using this plugin, I noticed that failing commands do not result in this indicator being added to the prompt. I believe the issue is that _osc133_setup is running before the prompt, and overwrites the value of $status. I determined this by commenting out each of the functions in the plugin and testing the behavior; with _osc133_setup removed the status reporting works again (though at the expense of breaking some of the functionality of this plugin).

However, normally fish handles this situation (a function being declared with --on-event fish_prompt) correctly. For example, with the above prompt, if I then add this:

function greet --on-event fish_prompt
  echo "Hello!"
end

...then when I run false, I see this:

~> false
Hello!
~[1]>

Where the [1] is the indication that false returned a nonzero exit code. So even though greet is running echo which returns zero, fish knows not to let that override the $status value set after false exited.

So, I'm not sure why this plugin overwrites $status when the reduced example above seems to work fine. But maybe this info will be of some use if you feel inclined to look into the issue.

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.