zzamboni / elvish-modules Goto Github PK
View Code? Open in Web Editor NEWVarious modules for Elvish
License: MIT License
Various modules for Elvish
License: MIT License
Currently the alias module uses the deprecated ~/.elvish folder. It would be good to use the same folder structure as elvish does now.
In Elvish 0.12 on macOS Sierra 10.13.6, I added the following to ~/.elvish/rc.elv per the dir.org
file:
use github.com/zzamboni/elvish-modules/dir
edit:insert:binding[Alt-b] = $dir:&left-word-or-prev-dir
edit:insert:binding[Alt-f] = $dir:&right-word-or-next-dir
edit:insert:binding[Alt-i] = $dir:&dir-chooser
which upon restarting Elvish generates the following error message:
Exception: value should be function
/Users/alchou/.elvish/rc.elv, line 18: edit:insert:binding[Alt-b] = $dir:&left-word-or-prev-dir
wherein the substring $dir:
is underlined.
For some reason that I have not finally debugged, adding ftcs-command-start >/dev/tty
to the prompt causes the histlist (bound by default to Ctrl-R
) to render much slower than usual. (Usually comes up within a split second, on a full screen terminal takes 1-2 seconds to come up after iterm2:init
has been called.) Occurs only in iTerm, calling iterm2:init
in Terminal.app doesn't have this effect.
I fixed it by emitting iterm2:ftcs-command-finished
before producing the history list, using the following stanza in rc.elv
(after calling iterm2:init
):
set edit:insert:binding[Ctrl-R] = {
iterm2:ftcs-command-finished
edit:histlist:start
}
I hope to spare somebody a few minutes of googling and debugging by this. If anybody more knowledgeable than me can explain to me a bit more thoroughly what's going on, I wouldn't mind :)
(Reported by @krader1961)
According to the documentation:
A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers
Currently semver considers missing Y or Z as zeros, so that:
> semver:eq 1.0 1.0.0
▶ $true
This should produce an error - maybe there should be a &non-strict
option to allow parsing non-strictly-compliant numbers.
FYI, while responding to elves/elvish#1416 I noticed that alias.org has two lines of this form:
var content = (cat $file | slurp)
There isn't any need for cat
and a pipeline, just do var content = (slurp < $file)
. I know your alias
module is probably no longer being actively maintained now that Elvish has edit:add-var
but you should still probably review all your Elvish code for useless uses of cat
. 😺
V0.17 makes some syntax changes and there are many deprecation warnings currently visible. See the upgrader script: https://github.com/elves/upgrade-scripts-for-0.17
The alias module at the moment automatically saves aliases defined with alias:new
to individual files under ~/.elvish/aliases/
. This is nice for interactive use, but I am not convinced of this being a good thing. For the most part, aliases should be defined in the config file, and I think it is a good thing that, if they need to be persistent, they should be defined there so that the config file is a "single source of truth". Maybe a new alias:save
function could be added for when you want to save certain aliases, but not be the default behavior.
I couldn't get alias:new cd "use github.com/zzamboni/elvish-modules/dir; dir:cd"
to work until I made sure the line -exports- = (alias:export)
appeared in rc.elv after it.
This question was posed by @dcuadrado on IM an hour ago:
in the notifier is there a way to know if the process failed? I'd like it to say something out loud if the command failed
The answer is, no, given the current implementation. However, if the implementation were changed to use the edit:after-command
hook introduced by commit elves/elvish@e2f8100 it could both report sub-second durations and the status of the command; i.e., whether or not it failed and if it failed how it failed.
Absolute beginner in Elvish, sorry if this is something silly, but I just tried this:
#! /usr/bin/env nix-shell
#! nix-shell -i elvish -p elvish
use epm
epm:install github.com/zzamboni/elvish-modules
use github.com/zzamboni/elvish-modules/dir
use github.com/zzamboni/elvish-modules/alias
alias:new cd "use github.com/zzamboni/elvish-modules/dir; dir:cd"
cd bastion
cd -
And got:
Exception: compilation error: variable $edit:current-command not found
/Users/juliano/.elvish/lib/github.com/zzamboni/elvish-modules/dir.elv, line 89: if (> (count $edit:current-command) 0) {
/Users/juliano/git/NoRedInk/tf-all.elv, line 7: use github.com/zzamboni/elvish-modules/dir
except
has been replaced with catch
...
Hello, I just discovered elvish, and I am loving it.
I can use:
use github.com/iwoloschin/elvish-packages/update
use epm
epm:install &silent-if-installed ^
github.com/zzamboni/elvish-modules ^
github.com/zzamboni/elvish-completions ^
github.com/zzamboni/elvish-themes ^
github.com/xiaq/edit.elv ^
github.com/muesli/elvish-libs ^
without issues
But, I am trying to use bang-bang or aliases and is failing
use github.com/zzamboni/elvish-completions/alias
Exception: no such module: github.com/zzamboni/elvish-completions/alias
[tty 46], line 1: use github.com/zzamboni/elvish-completions/alias
Any idea of what am I doing wrong?
Thanks
Right now this happens (|
being the cursor)
~> |command
~> (|)command
I checked in PyCharm, VSCode and Sublime Text and they all only insert a single character when it's typed right next to a character. This could be configurable I suppose.
Steps to reproduce:
~> use github.com/zzamboni/elvish-modules/util
~> util:electric-delimiters
öäü
)[binding error] index not at rune boundary
For interactive applications like editors (vim, nano), pagers (less), shells (elvish, bash) and others getting a notification of the time the command ran isn't really useful.
It would be nice if it was possible to pass a list of command names to ignore to long-running-notifications
Not sure which commit, but something in the last day seems to have broken aliases. As far as I can tell aliases are simply not being found and launched. The best example is probably just ls:
alias:def ls e:ls -G
If you type 'ls' it should return with colors (on macOS at least), but instead it's just a plain boring white ls output.
At some point, Apple in their infinite wisdom has changed the escape conventions for filenames dragged from the Finder into the terminal, so the current code no longer works.
This seems to be the new convention:
Example: A file named a'b\c
gets entered as '…/a\'b\\c'
, where …
is the directory part.
I don't know of any shell that obeys these escape conventions – certainly not bash
or zsh
– so I don't know what Apple has been thinking. And since these seem so awfully wrong, I suspect it may get changed yet again. If not, the new convention is easy enough to parse, but I don't have a moment to spare for this in the foreseeable future.
The error messages (e.g. "Beginning/End of directory history!") are messing with my prompt. I have to press Enter
or run clear
to have it restored. Would it be possible to implement some mechanism to disable them or customize where/how they will be printed? E.g. I was thinking about showing them in the rprompt.
An idea: have some variable, say dir:print-error
, whose default value would be the current behaviour:
print-error = [msg]{
echo $msg > /dev/tty
}
and then functions like e.g. back
would use it:
fn back {
if (> $-cursor 0) {
-cursor = (- $-cursor 1)
builtin:cd $-dirstack[$-cursor]
} else {
$print-error "Beginning of directory history!" # <= here
}
}
Then I would be able to override dir:print-error
in my rc.elv
to implement the behaviour that I want.
Since (+ 2 2)
returns a float64 now, the examples for tests are broken.
i.e. the first example in https://github.com/zzamboni/elvish-modules/blob/master/test.org#writing-tests would need to be changed to
(test:check { eq ( + 2 2 ) (float64 4) } True arithmetic)
for it to be $true (I'd PR but I don't have emacs)
-exports- = (alias:export)
needs to appear in the rc.elv file and come after all uses of the alias
command.(Reported by @krader1961)
According to the documentation:
Build metadata MUST be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85, 1.0.0+21AF26D3—-117B344092BD.
Currently the metadata is considered as part of the build string, so it's used in the comparison:
semver:eq 1.0.0-alpha+001 1.0.0+20130313144700 1.0.0-beta+exp.sha.5114f85 1.0.0+21AF26D3—-117B344092BD
▶ $false
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.