dolmen / angel-ps1 Goto Github PK
View Code? Open in Web Editor NEWYour fancy shell prompt fed by your guardian angel
Home Page: https://twitter.com/nglPS1
License: GNU Affero General Public License v3.0
Your fancy shell prompt fed by your guardian angel
Home Page: https://twitter.com/nglPS1
License: GNU Affero General Public License v3.0
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
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);
}
angel quit
should restore shell options as they were before angel-PS1 was loaded: promptpercent
, nopromptbang
, nopromptsubst
.
Fo example, use an apple for OS X ( U+F8FF).
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
.
LoadAvg threshold should be multiplied by the number of CPU.
Plus I thing 0.8 is a bit low.
When we exit from fish
with angel-PS1
loaded inside, the angel doesn't terminate. It should instead be told to quit or be killed.
Add lib/AngelPS1/System/darwin.pm
for OS X support.
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.
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.
I just want to check if this will work with Oh My Zsh.
Report the current perl version set by plenv.
Design idea: use Unicode superscripts and subscripts.
$ perl -C -E 'say "perl 5.10.1: \x{2075}10\x{2081}"'
perl 5.10.1: ⁵10₁
On Mac OS X a login shell starts with a "-" .
I had the same problem with liquidprompt. See LudovicRousseau/liquidprompt@86f8dba
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 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.
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:
--font
command-line option to let the user gives us the path of the font file used to render characters in its terminalAs 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:
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
Get inspiration from olivierverdier/zsh-git-prompt for Git plugin output.
magicmonty/bash-git-prompt (bash port)
Also check the Haskell implementation of git status
parsing.
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
has an history handling bug that makes the current implementation (f88f0ee) pollute the interactive shell history with lines that part of our shell code:
endif
and angel leave
angel
controller the history is polluted with 20 entries (all the lines of the switch
statement except the first one)angel-PS1
unusable with tcsh
.tcsh
versions:
tcsh 6.17.06 (Astron) 2011-04-15 (i686-intel-linux) options wide,nls,dl,al,kan,rh,nd,color,filec
Devel::Cover has a bug that makes t/41-count_jobs.t
fail when running under coverage. See pjcj/Devel--Cover#152.
$ perl -MDevel::Cover -I lib t/41-count_jobs.t
...
Operation "bool": no method found, argument in overloaded package Term::Chrome at lib/AngelPS1/Plugin/Jobs.pm line 20.
lib/AngelPS1/Plugin/Shell.pm line 20
This ticket is just to track the fix of Devel::Cover.
ivanwills/App-PS1, made by @ivanwills (cpan:IANWILLS).
https://metacpan.org/pod/distribution/App-PS1/bin/app-ps1
The angel-PS1 documentation is embeded in POD.
It would be useful to have the core plugins documentation and the API available to plugins published on the web.
Ideas for export:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.