GithubHelp home page GithubHelp logo

dolmen / angel-ps1 Goto Github PK

View Code? Open in Web Editor NEW
61.0 6.0 3.0 520 KB

Your fancy shell prompt fed by your guardian angel

Home Page: https://twitter.com/nglPS1

License: GNU Affero General Public License v3.0

Perl 100.00%
unix bash zsh ksh fish-shell mksh prompt-toolkit prompt powerline shell-prompt

angel-ps1's People

Contributors

dolmen avatar hughsimpson avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

angel-ps1's Issues

Escape wildcards in shell code

The shell code generated is evaluated with eval $(angel-PS1) as indicated in the documentation.
Due to the use of $( ... ), this code is subject to wildard expansion. And we have a wildcard in the case ... esac block of the bash code.
Try this in bash:

touch 'aaaaaa)'
angel-PS1 | tee foo.bash
echo $(cat foo.bash)

=> The "*)" in the shell code is expanded.

A better demonstration of the issue:

$ echo $(echo 'an*')
angel-PS1

"pmset -g batt" parsing error on MacOS

When 100% charged on MacOS.

$ pmset -g batt
Now drawing from 'AC Power'
 -InternalBattery-0 (id=4718691)	100%; charged; 0:00 remaining present: true

$
$ eval `./angel-PS1`
angel installed.
Use of uninitialized value $1 in division (/) at ./angel-PS1 line 2183.

the following code can't parsing the result

      return sub {
          my $pmset_batt = `pmset -g batt`;

          # 37%; AC attached; not charging
          # 8%; charging; 2:46 remaining
          # 9%; discharging; (no estimate)
          # 7%; discharging; 0:13 remaining
          $pmset_batt =~ m/\t([0-9]+)%;.* (dis)?charging/;
          my $level = $1 / 100;
          my $charging = ! defined $2;

          return ($level, $charging);
      }

[fish] completion is not erased when leaving

With fish 1.23.1 (from Ubuntu 12.04), the completions for the angel command are not properly erased after angel leave. It looks like complete -c angel -e doesn't work. Seems to be a bug in fish.

OS X support

Add lib/AngelPS1/System/darwin.pm for OS X support.

/usr/local/bin/zsh is not a supported shell

I installed a more recent version of zsh in /usr/local/bin and that's what I use as my shell, but angel-PS1 doesn't recognize it:

angel-PS1: /usr/local/bin/zsh is not a supported shell: Can't locate AngelPS1/Shell//usr/local/bin/zsh.pm in @INC (@INC contains: /Users/dserodi/.config/angel-PS1 /etc/xdg/angel-PS1 /Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16 /Network/Library/Perl/5.16/darwin-thread-multi-2level /Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2 /System/Library/Perl/5.16/darwin-thread-multi-2level /System/Library/Perl/5.16 /System/Library/Perl/Extras/5.16/darwin-thread-multi-2level /System/Library/Perl/Extras/5.16 .) at AngelPS1/Shell.pm line 62.

This happens both on master and develop branches, and the error above is from the develop branch.

Embed the angel in urxvt

urxvt is a terminal emulator for X that embeds Perl. It also offers the AnyEvent API (see urxvt::anyevent).

The angel part of angel-PS1 could be embedded in urxvt and used by processes running on the same host and user (because the most interesting plugins are user-dependent and/or $PWD-dependent). The angel-PS1 launcher would have to detect that backend, and use it instead of forking its own angel.

Note: so far, this is just an idea. I haven't started to write a proof of concept.

Bad file descriptor error when using with zsh

I get the following error when trying to use with ZSH on Windows Subsystem for Linux:

angel-PS1: AngelPS1/Prompt/Default.pm load error: Bad file descriptor at ./angel-PS1 line 2775

AngelPS1::System lacks error handling

AngelPS1::System lacks proper error handling to display nice error messages to the user when an operating system is not supported.
See #8 for an example of the disaster.

Add glyph check API

The use of Unicode code points (or other glyphs) in plugins can only work properly if the plugin is able to detect if the terminal will be able to display the glyph. We should let the user tell angel-PS1 what font is used to render the terminal and add an API that plugins could use to check if a given glyph is available in the font.

Design idea:

  • add a --font command-line option to let the user gives us the path of the font file used to render characters in its terminal
  • add a utility function that will parse the font file, extract its glyph names and/or Unicode codepoints. This Adobe tool may help.
  • add a utility function that will check if a particular glyph is available

As parsing the font file will probably rely on external tools, this feature should be optional (plugins should be able to work without it).

Useful links:

Not working under perl 5.26.0 or newer.

When running the fatpacked version of angel-PS1, it dies with the following error -- if the invoking perl is newer than 5.26.0

% eval `./angel-PS1`
angel-PS1: Unimplemented: POSIX::tmpnam(): use File::Temp instead at /Users/st21277/bin/angel-PS1 line 2856.

Some additional info:

% which perl
/Users/gugod/perl5/perlbrew/perls/perl-5.26.1/bin/perl
% echo $SHELL
/bin/zsh

The subroutine POSIX::tmpnam() was simply removed. See: https://perldoc.perl.org/perl5260delta.html#POSIX%3a%3atmpnam()-has-been-removed

[mksh] examples/simple.PS1 failure on perl 5.10 - 5.14

With perl 5.10 to 5.14 (perl 5.8.3, 5.8.9, 5.18.1 are ok), the mksh shell implementation fails:

/home/dolmen/Code/angel-PS1 $ mksh
/home/dolmen/Code/angel-PS1 $ eval $(perl -Ilib bin/angel-PS1 -c examples/simple.PS1 )                                     
Loading examples/simple.PS1...
angel installed.
angel PS1 eval: Not a CODE reference at lib/AngelPS1/Compiler.pm line 27.
[angel sick!!] /home/dolmen/Code/angel-PS1$ 

The test t/70-examples.t reproduces the issue. Travis-CI shows it.

This looks like a dirty perl bug fixed for 5.16.

[tcsh] history pollution

tcsh has an history handling bug that makes the current implementation (f88f0ee) pollute the interactive shell history with lines that part of our shell code:

  • every time the prompt is displayed two entries are injected in the history: endif and angel leave
  • every time the user runs the angel controller the history is polluted with 20 entries (all the lines of the switch statement except the first one)
    This bug makes angel-PS1 unusable with tcsh.

tcsh versions:

  • Ubuntu 12.04: tcsh 6.17.06 (Astron) 2011-04-15 (i686-intel-linux) options wide,nls,dl,al,kan,rh,nd,color,filec

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.