Nouvelle config (passage à elvish 0.16.1)
This commit is contained in:
parent
0ebaf3b5a0
commit
ff9cefd28f
@ -1,28 +0,0 @@
|
||||
#alias:new add_badips e:echo
|
||||
fn add_badips [@_args]{
|
||||
use moi/util/ip
|
||||
use moi/util/list
|
||||
use moi/util/map
|
||||
use moi/util/number
|
||||
use str
|
||||
|
||||
local:f = ~/bad_ips.txt
|
||||
local:ips = [ (cat $f) ]
|
||||
local:m = (map:to-set $ips)
|
||||
local:c = 0
|
||||
each [e]{
|
||||
local:cond = (and (not (has-key $m $e)) (ip:is-ipv4 $e))
|
||||
if $cond {
|
||||
echo $e ajoutée
|
||||
c = (number:++ $c)
|
||||
m[$e] = $nil
|
||||
ips = [ (all $ips) $e ]
|
||||
}
|
||||
} $_args
|
||||
if (> $c 0) {
|
||||
ips = [ (list:sort $ip:cmp4~ $ips) ]
|
||||
}
|
||||
local:result = (str:join "\n" $ips)
|
||||
echo $result > $f
|
||||
echo $c' IPs ajoutées ('(count $ips)' au total)'
|
||||
}
|
@ -1,38 +1,39 @@
|
||||
#alias:new archiver e:archiver
|
||||
fn archiver [@_args]{
|
||||
edit:add-var archiver~ [@argv]{
|
||||
use str
|
||||
help = {
|
||||
echo "Usage : archiver [(-zlxgb)] <file to compress>"
|
||||
return
|
||||
}
|
||||
if (or (== (count $_args) 0) (eq $_args[0] -h)) {
|
||||
if (or (== (count $argv) 0) (eq $argv[0] -h)) {
|
||||
$help
|
||||
}
|
||||
local:format = zst
|
||||
local:o = $_args[0]
|
||||
if (and (has-prefix $o -) (> (count $o) 1)) {
|
||||
local:o = $argv[0]
|
||||
if (and (str:has-prefix $o -) (> (count $o) 1)) {
|
||||
o = $o[1]
|
||||
local:m = [
|
||||
&z=zst
|
||||
&l=lz4
|
||||
&x=xz
|
||||
&g=gzip
|
||||
&g=gz
|
||||
&b=bz2
|
||||
]
|
||||
if (not (has-key $m $o)) {
|
||||
$help
|
||||
}
|
||||
format = $m[$o]
|
||||
_args = $_args[1:]
|
||||
argv = $argv[1..]
|
||||
}
|
||||
if (== (count $_args) 0) {
|
||||
if (== (count $argv) 0) {
|
||||
$help
|
||||
}
|
||||
peach [f]{
|
||||
local:f = $f
|
||||
if (eq $f[-1] /) {
|
||||
f = $f[:-1]
|
||||
f = $f[..-1]
|
||||
}
|
||||
e:arc archive $f'.tar.'$format $f
|
||||
echo "'"$f"'" archivé
|
||||
} $_args
|
||||
} $argv
|
||||
}
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
#alias:new bat e:bat
|
||||
fn bat [@_args]{
|
||||
styles = [ --style -n --number -p --plain -pp ]
|
||||
has_style = $false
|
||||
for e $_args {
|
||||
if (has-value $styles $e) {
|
||||
has_style = true
|
||||
break
|
||||
}
|
||||
}
|
||||
@pargs = $@_args
|
||||
if (not $has_style) {
|
||||
@pargs = -p $@_args
|
||||
}
|
||||
e:bat $@pargs
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#alias:new br e:broot -dp
|
||||
#fn br [@_args]{ e:broot -dp $@_args }
|
||||
fn br [@_args]{
|
||||
f = (mktemp)
|
||||
try {
|
||||
e:broot --outcmd $f -dp $@_args
|
||||
} except e {
|
||||
rm -f $f
|
||||
return
|
||||
}
|
||||
try {
|
||||
-source $f
|
||||
} except e {
|
||||
} finally {
|
||||
rm -f $f
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
#alias:new cat bat -pp
|
||||
fn cat [@_args]{ bat -pp $@_args }
|
@ -1,36 +0,0 @@
|
||||
#alias:new clean_known_hosts e:cat
|
||||
fn clean_known_hosts [@_args]{
|
||||
use str
|
||||
use moi/util/condition
|
||||
use moi/util/list
|
||||
use moi/util/ip
|
||||
fn less [cmp e1 e2]{ < ($cmp $e1 $e2) 0 }
|
||||
fn sort-host [e1 e2]{
|
||||
local:i1 = (condition:set (ip:is-ip $e1) 1 0)
|
||||
local:i2 = (condition:set (ip:is-ip $e2) 1 0)
|
||||
if (!= $i1 $i2) {
|
||||
< $i1 $i2
|
||||
} elif (== $i1 0) {
|
||||
<s $e1 $e2
|
||||
} else {
|
||||
less $ip:cmp~ $e1 $e2
|
||||
}
|
||||
}
|
||||
|
||||
local:khosts = [&]
|
||||
cat ~/.ssh/known_hosts | eawk [_ hosts @rest]{
|
||||
local:key = (str:join ' ' $rest)
|
||||
if (not (has-key $khosts $key)) {
|
||||
khosts[$key] = [&]
|
||||
}
|
||||
str:split , $hosts | each [h]{
|
||||
khosts[$key][$h] = $nil
|
||||
}
|
||||
}
|
||||
|
||||
local:lines = [(keys $khosts | each [key]{
|
||||
local:hosts = (keys $khosts[$key] | order &less-than=$sort-host~ | str:join ,)
|
||||
put $hosts $key | str:join ' '
|
||||
})]
|
||||
echo (str:join "\n" $lines) > ~/.ssh/known_hosts
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
#alias:new cp e:cp -iv
|
||||
fn cp [@_args]{ e:cp -iv $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new dcd e:broot --only-folder --cmd
|
||||
fn dcd [@_args]{ br --only-folders --cmd (joins ' ' $_args)' :cd' }
|
@ -1,8 +1,8 @@
|
||||
#alias:new desarchiver e:desarchiver
|
||||
fn desarchiver [@_args]{
|
||||
edit:add-var desarchiver~ [@argv]{
|
||||
peach [f]{
|
||||
local:f = $f
|
||||
e:arc unarchive $f
|
||||
echo "'"$f"'" désarchivé
|
||||
} $_args
|
||||
} $argv
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
#alias:new df e:df -h
|
||||
fn df [@_args]{ e:df -h $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new diff e:colordiff
|
||||
fn diff [@_args]{ e:colordiff $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new dig e:dig +noall +answer
|
||||
fn dig [@_args]{ e:dig +noall +answer $@_args }
|
@ -1,7 +1,6 @@
|
||||
#alias:new digall e:dig ANY +noall +answer
|
||||
fn digall [@_args]{
|
||||
edit:add-var digall~ [@argv]{
|
||||
use moi/util/list
|
||||
use moi/util/strutil
|
||||
use moi/util/strutil
|
||||
use str
|
||||
|
||||
local:default_records = [
|
||||
@ -31,9 +30,9 @@ fn digall [@_args]{
|
||||
local:use_dig = $true
|
||||
|
||||
fn init []{
|
||||
if (and (> (count $_args) 0) (is $_args[0] -d)) {
|
||||
if (and (> (count $argv) 0) (is $argv[0] -d)) {
|
||||
use_dig = $false
|
||||
_args = $_args[1:]
|
||||
argv = $argv[1:]
|
||||
}
|
||||
each [e]{
|
||||
if (is $e[0] '+') {
|
||||
@ -45,7 +44,7 @@ fn digall [@_args]{
|
||||
} else {
|
||||
domains = [ (all $domains) $e ]
|
||||
}
|
||||
} $_args
|
||||
} $argv
|
||||
if (== (count $records) 0) {
|
||||
records = $default_records
|
||||
}
|
||||
@ -53,7 +52,7 @@ fn digall [@_args]{
|
||||
|
||||
fn format [results]{
|
||||
eawk [_ @args]{
|
||||
put [ $args[0] (all $args[2:]) ]
|
||||
put [ $args[0] (all $args[2..]) ]
|
||||
} $results | list:remove-duplicate | list:sort [l1 l2]{
|
||||
local:c = (str:compare $l1[0] $l2[0])
|
||||
if (== $c 0) {
|
||||
|
@ -1,2 +0,0 @@
|
||||
#alias:new du e:du -h
|
||||
fn du [@_args]{ e:du -h $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new git e:hub
|
||||
fn git [@_args]{ e:hub $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new grep e:grep --color=tty -d skip
|
||||
fn grep [@_args]{ e:grep --color=tty -d skip $@_args }
|
@ -1,34 +0,0 @@
|
||||
#alias:new history edit:command-history | each [h]{ put $h['cmd'] }
|
||||
fn history [@_args]{
|
||||
use str
|
||||
use moi/util/list
|
||||
@history = (edit:command-history | each [h]{ put $h['cmd'] })
|
||||
@ch = (list:reverse $history | list:remove-duplicate | list:reverse)
|
||||
if (list:empty $_args) {
|
||||
each [h]{ echo $h } $ch
|
||||
return
|
||||
}
|
||||
action @rest = $_args[0] (take 1 $_args)
|
||||
has-rest = (list:not-empty $rest)
|
||||
if (and (is $action --cmd) $has-rest) {
|
||||
eawk [h cmd @_]{
|
||||
if (has-value $rest $cmd) {
|
||||
echo $h
|
||||
}
|
||||
} $ch
|
||||
} elif (and (is $action --search) $has-rest) {
|
||||
each [h]{
|
||||
if (list:exists [_ m]{ str:contains $h $m } $rest) {
|
||||
echo $h
|
||||
}
|
||||
} $ch
|
||||
} elif (and (is $action --delete) $has-rest) {
|
||||
each [h]{
|
||||
if (list:exists [_ m]{ str:contains $h $m } $rest) {
|
||||
put $h
|
||||
}
|
||||
} $history
|
||||
} else {
|
||||
echo (styled 'Usage: history [(--search|--cmd|--delete) args...' bold red)
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
#alias:new ip-of e:is-ip
|
||||
fn ip-of [@_args]{
|
||||
use str
|
||||
use moi/util/condition
|
||||
use moi/util/ip
|
||||
|
||||
fn less [cmp e1 e2]{ < ($cmp $e1 $e2) 0 }
|
||||
|
||||
fn sort-ip [e1 e2]{
|
||||
local:i1 = (condition:set (ip:is-ipv4 $e1) 0 (condition:set (ip:is-ipv6 $e1) 1 2))
|
||||
local:i2 = (condition:set (ip:is-ipv4 $e2) 0 (condition:set (ip:is-ipv6 $e2) 1 2))
|
||||
if (!= $i1 $i2) {
|
||||
< $i1 $i2
|
||||
} elif (== $i1 2) {
|
||||
<s $e1 $e2
|
||||
} elif (== $i1 1) {
|
||||
less $ip:cmp6~ $e1 $e2
|
||||
} else {
|
||||
less $ip:cmp4~ $e1 $e2
|
||||
}
|
||||
}
|
||||
|
||||
fn dnssolve [d]{
|
||||
local:result = [
|
||||
&ips=[&]
|
||||
&resolvers=''
|
||||
&txt=''
|
||||
]
|
||||
e:dnscrypt-proxy --resolve $d | peach [l]{
|
||||
if (has-prefix $l 'IP addresses:') {
|
||||
local:ips = (str:trim-space (str:trim-prefix $l 'IP addresses:'))
|
||||
splits ', ' $ips | peach [e]{
|
||||
local:e = $e
|
||||
if (ip:is-ip $e) {
|
||||
result[ips][$e] = $nil
|
||||
}
|
||||
}
|
||||
} elif (has-prefix $l 'TXT records:') {
|
||||
result[txt] = (str:trim-space (str:trim-prefix $l 'TXT records:'))
|
||||
} elif (has-prefix $l 'Resolver IP:') {
|
||||
result[resolvers] = (str:trim-space (str:trim-prefix $l 'Resolver IP:'))
|
||||
}
|
||||
}
|
||||
put $result
|
||||
}
|
||||
|
||||
local:hosts = [&]
|
||||
cat /etc/hosts | peach [l]{
|
||||
local:l = $l
|
||||
l = (str:trim-space $l)
|
||||
if (and (not-eq $l '') (not-eq $l[0] '#')) {
|
||||
put $l
|
||||
}
|
||||
} | eawk [_ ip @domains]{
|
||||
peach [d]{
|
||||
local:d = $d
|
||||
if (has-key $hosts $d) {
|
||||
hosts[$d][$ip] = $nil
|
||||
} else {
|
||||
hosts[$d] = [&$ip=$nil]
|
||||
}
|
||||
} $domains
|
||||
}
|
||||
|
||||
local:remote = [&]
|
||||
peach [d]{
|
||||
local:d = $d
|
||||
local:solve = (dnssolve $d)
|
||||
if (> (keys $solve[ips] | count) 0) {
|
||||
remote[$d] = $solve
|
||||
}
|
||||
} $_args
|
||||
|
||||
each [d]{
|
||||
local:exists = $false
|
||||
echo (styled 'Resolving '$d'…' bright-green)
|
||||
echo
|
||||
if (has-key $hosts $d) {
|
||||
exists = $true
|
||||
echo (styled ' local:' bright-yellow)
|
||||
keys $hosts[$d] | order &less-than=$sort-ip~ | each [ip]{
|
||||
echo ' - '$ip
|
||||
}
|
||||
}
|
||||
if (has-key $remote $d) {
|
||||
exists = $true
|
||||
local:info = $remote[$d]
|
||||
echo (styled ' remote:' bright-yellow)
|
||||
echo ' IPs:'
|
||||
keys $info[ips] | order &less-than=$sort-ip~ | each [ip]{
|
||||
echo ' - '$ip
|
||||
}
|
||||
echo ' Resolvers: '$info[resolvers]
|
||||
echo ' TXT records: '$info[txt]
|
||||
}
|
||||
if (not $exists) {
|
||||
echo (styled 'No info found' bright-red)
|
||||
}
|
||||
echo
|
||||
} $_args
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
#alias:new la e:ls -a -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify
|
||||
fn la [@_args]{ e:ls -a -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new ll e:ls -lh -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify
|
||||
fn ll [@_args]{ e:ls -lh -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new lla e:ls -la -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify
|
||||
fn lla [@_args]{ e:ls -la -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify $@_args }
|
@ -1,2 +1,14 @@
|
||||
#alias:new ls e:ls -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify
|
||||
fn ls [@_args]{ e:ls -N --color=auto --group-directories-first --ignore=lost+found --time-style=+"%Y.%m.%d %H:%M" --indicator-style=classify $@_args }
|
||||
fn -ls [@argv]{
|
||||
e:ls -N --color=auto --group-directories-first --ignore=lost+found '--time-style=+"%Y.%m.%d %H:%M"' --indicator-style=classify $@argv
|
||||
}
|
||||
|
||||
fn -go-ls [@argv]{
|
||||
e:go-ls --group-directories-first -T '+%Y.%m.%d %H:%M' --git $@argv
|
||||
}
|
||||
|
||||
local:cmd = $-go-ls~
|
||||
|
||||
edit:add-var ls~ [@argv]{ $cmd $@argv }
|
||||
edit:add-var la~ [@argv]{ $cmd -a $@argv }
|
||||
edit:add-var ll~ [@argv]{ $cmd -lh $@argv }
|
||||
edit:add-var lla~ [@argv]{ $cmd -lha $@argv }
|
||||
|
@ -1,29 +0,0 @@
|
||||
#alias:new mdig e:dig
|
||||
fn mdig [@_args]{
|
||||
if (== (count $_args) 0) {
|
||||
fail (styled "Veuillez saisir au moins un nom de domaine…" bold red)
|
||||
}
|
||||
ns = []
|
||||
@hosts = $@_args
|
||||
if (has-prefix $_args[0] '@') {
|
||||
ns = $_args[0]
|
||||
@hosts = (drop 1 $hosts)
|
||||
}
|
||||
if (== (count $hosts) 0) {
|
||||
fail (styled "Veuillez saisir au moins un nom de domaine…" bold red)
|
||||
}
|
||||
for h $hosts {
|
||||
@ipv4 = (e:dig $ns $h A +short)
|
||||
@ipv6 = (e:dig $ns $h AAAA +short)
|
||||
if (== (count $ipv4) 0) {
|
||||
@ipv4 = "<unknown>"
|
||||
}
|
||||
if (== (count $ipv6) 0) {
|
||||
@ipv6 = "<unknown>"
|
||||
}
|
||||
echo (styled $h bold yellow)
|
||||
echo (styled 'A ' bright-red)$@ipv4
|
||||
echo (styled 'AAAA ' bright-red)$@ipv6
|
||||
echo "----------------------"
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#alias:new meteo e:curl 'wttr.in/?lang=fr'
|
||||
fn meteo [@_args]{
|
||||
curl --connect-timeout 2 "wttr.in/"(joins '' $_args)"?lang=fr"
|
||||
edit:add-var meteo~ [@argv]{
|
||||
use str
|
||||
#curl --connect-timeout 2 "wttr.in/"(joins '' $_args)"?lang=fr"
|
||||
e:curlie -s --connect-timeout 2 "wttr.in/"(str:join '' $argv)"?lang=fr"
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
#alias:new midi e:fluidsynth -a pulseaudio /usr/share/soundfonts/FluidR3_GM.sf2
|
||||
fn midi [@_args]{ e:fluidsynth -a pulseaudio /usr/share/soundfonts/FluidR3_GM.sf2 $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new mv e:mv -iv
|
||||
fn mv [@_args]{ e:mv -iv $@_args }
|
@ -1,4 +1 @@
|
||||
#alias:new pacmanhisto cat /var/log/pacman.log
|
||||
fn pacmanhisto [@_args]{
|
||||
cat /var/log/pacman.log | grep "ALPM" | grep $@_args
|
||||
}
|
||||
edit:add-var pacmanhisto~ [@argv]{ e:cat /var/log/pacman.log | e:grep "ALPM" | e:grep $@argv }
|
||||
|
@ -1,2 +0,0 @@
|
||||
#alias:new pf e:pkgfile -vri
|
||||
fn pf [@_args]{ e:pkgfile -vri $@_args }
|
@ -1,9 +1,8 @@
|
||||
#alias:new publicip curl ifconfig.co/ip
|
||||
fn publicip {
|
||||
edit:add-var publicip~ [@argv]{
|
||||
f = [t]{
|
||||
use moi/util/condition
|
||||
t = condition:set (eq $t -6) -6 -4
|
||||
l = condition:set (eq $t -6) 'IPv6: ' 'IPv4: '
|
||||
t = (condition:cset (eq $t -6) -6 -4)
|
||||
l = (condition:cset (eq $t -6) 'IPv6: ' 'IPv4: ')
|
||||
curl $t ifconfig.co/ip 2> /dev/null | each [ip]{ echo (styled $l bold yellow) $ip }
|
||||
}
|
||||
$f -4
|
||||
|
@ -1,11 +0,0 @@
|
||||
#alias:new rename perl-rename
|
||||
fn rename [@_args]{
|
||||
e:perl-rename -n $@_args
|
||||
use github.com/zzamboni/elvish-modules/util
|
||||
if (util:y-or-n &style=bright-yellow 'Renommer? ') {
|
||||
e:perl-rename -v $@args
|
||||
echo (styled 'Succès' bold green)
|
||||
} else {
|
||||
echo (styled 'Abandon' bold red)
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
#alias:new rm e:rm -Iv
|
||||
fn rm [@_args]{ e:rm -Iv $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new timidity e:timidity -a -K -1
|
||||
fn timidity [@_args]{ e:timidity -a -K -1 $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new tree e:tree -puhC --dirsfirst --du -D
|
||||
fn tree [@_args]{ e:tree -puhC --dirsfirst --du -D $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new trsen e:rlwrap trans -b -t en
|
||||
fn trsen [@_args]{ e:rlwrap trans -b -t en $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new trsfr e:rlwrap trans -b -t fr
|
||||
fn trsfr [@_args]{ e:rlwrap trans -b -t fr $@_args }
|
@ -1,6 +1,6 @@
|
||||
#alias:new upd and ?(mirror-check --fast) (sudo pacman -Syu)
|
||||
fn upd [@_args]{
|
||||
edit:add-var upd~ [@args]{
|
||||
if ?(mirror-check --fast) {
|
||||
sudo pacman -Syu
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
#alias:new vb e:vim /home/benjamin/.bashrc
|
||||
fn vb [@_args]{ e:vim /home/benjamin/.bashrc $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new vc e:vim /home/benjamin/.vimrc
|
||||
fn vc [@_args]{ e:vim /home/benjamin/.vimrc $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new vf e:vim /home/benjamin/.config/config.fish
|
||||
fn vf [@_args]{ e:vim /home/benjamin/.config/config.fish $@_args }
|
@ -1,2 +1,10 @@
|
||||
#alias:new vi e:vim
|
||||
fn vi [@_args]{ e:vim $@_args }
|
||||
local:cmd = $e:vim~
|
||||
|
||||
edit:add-var vi~ [@argv]{ $cmd $@argv }
|
||||
edit:add-var vb~ [@argv]{ $cmd $@argv ~/.bashrc }
|
||||
edit:add-var vc~ [@argv]{ $cmd $@argv ~/.vimrc }
|
||||
edit:add-var ve~ [@argv]{ $cmd $@argv ~/.config/elvish/rc.elv }
|
||||
edit:add-var vf~ [@argv]{ $cmd $@argv ~/.config/fish/config.fish }
|
||||
edit:add-var vp~ [@argv]{ $cmd $@argv PKGBUILD }
|
||||
edit:add-var vv~ [@argv]{ $cmd -R $@argv }
|
||||
edit:add-var vz~ [@argv]{ $cmd $@argv ~/.zshrc }
|
||||
|
@ -1,2 +0,0 @@
|
||||
#alias:new vp e:vim PKGBUILD
|
||||
fn vp [@_args]{ e:vim PKGBUILD $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new vv e:vim -R
|
||||
fn vv [@_args]{ e:vim -R $@_args }
|
@ -1,2 +0,0 @@
|
||||
#alias:new vz e:vim /home/benjamin/.zshrc
|
||||
fn vz [@_args]{ e:vim /home/benjamin/.zshrc $@_args }
|
@ -1 +0,0 @@
|
||||
|
@ -1,2 +1,3 @@
|
||||
#alias:new youtube-dl e:youtube-dl --no-check-certificate
|
||||
fn youtube-dl [@_args]{ e:youtube-dl --no-check-certificate $@_args }
|
||||
edit:add-var youtube-dl~ [@argv]{ e:youtube-dl --no-check-certificate $@argv }
|
||||
edit:add-var youtube-audio~ [@argv]{ e:youtube-dl --no-check-certificate -x --audio-format best $@argv }
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
#alias:new youtube_audio youtube-dl -x --audio-format best
|
||||
fn youtube_audio [@_args]{ youtube-dl -x --audio-format best $@_args }
|
@ -1 +0,0 @@
|
||||
Subproject commit 4933947f086421494cfb444b2d90ce0a51faa493
|
@ -1 +0,0 @@
|
||||
Subproject commit 5a361ca5ce20a57e1f80a9ee893c2423e63e7ee1
|
@ -1 +0,0 @@
|
||||
Subproject commit 97a5aa575fa60be55e61800d885e6108ccca04ff
|
@ -1 +0,0 @@
|
||||
Subproject commit 21e048ee6dca73c27d61068e03a113c97cf0a278
|
@ -1 +0,0 @@
|
||||
Subproject commit 3ff9fe88bb40dff3591d7e40e3c7dfa06c584e60
|
@ -1 +0,0 @@
|
||||
Subproject commit 1010ade24d1dee0a9b62506cfa86298158cac70f
|
@ -1,56 +0,0 @@
|
||||
use github.com/zzamboni/elvish-modules/alias
|
||||
|
||||
#fn pacman [@_args]{
|
||||
# if (and (== (count $_args) 0) (has-value [-S -Sy -Syu -Syyu -Su -Suu] $_args[0])) {
|
||||
# mirror-check --fast
|
||||
# }
|
||||
# e:pacman $@_args
|
||||
#}
|
||||
|
||||
alias:new cat bat -pp
|
||||
alias:new midi e:fluidsynth -a pulseaudio /usr/share/soundfonts/FluidR3_GM.sf2
|
||||
alias:new timidity e:timidity -a -K -1
|
||||
alias:new git e:hub
|
||||
alias:new dig e:dig +noall +answer
|
||||
|
||||
#alias:new pacmanhisto cat /var/log/pacman.log | grep "ALPM" | grep
|
||||
alias:new pf e:pkgfile -vri
|
||||
|
||||
alias:new trsen e:rlwrap trans -b -t en
|
||||
alias:new trsfr e:rlwrap trans -b -t fr
|
||||
|
||||
alias:new youtube-dl e:youtube-dl --no-check-certificate
|
||||
alias:new youtube_audio youtube-dl -x --audio-format best
|
||||
|
||||
#alias:new history edit:command-history
|
||||
|
||||
alias:new cp e:cp -iv
|
||||
alias:new mv e:mv -iv
|
||||
alias:new rm e:rm -Iv
|
||||
|
||||
@argls = -N --color=auto --group-directories-first --ignore=lost+found '--time-style=+"%Y.%m.%d %H:%M"' --indicator-style=classify
|
||||
#alias:new br e:broot -dp
|
||||
alias:new tree e:tree -puhC --dirsfirst --du -D
|
||||
alias:new ls e:ls $@argls
|
||||
alias:new la e:ls -a $@argls
|
||||
alias:new ll e:ls -lh $@argls
|
||||
alias:new lla e:ls -la $@argls
|
||||
|
||||
alias:new df e:df -h
|
||||
alias:new du e:du -h
|
||||
|
||||
alias:new diff e:colordiff
|
||||
alias:new grep e:grep --color=tty -d skip
|
||||
|
||||
alias:new vi e:vim
|
||||
alias:new vv e:vim -R
|
||||
alias:new vb e:vim ~/.bashrc
|
||||
alias:new vf e:vim ~/.config/config.fish
|
||||
alias:new vz e:vim ~/.zshrc
|
||||
alias:new vc e:vim ~/.vimrc
|
||||
alias:new vp e:vim PKGBUILD
|
||||
|
||||
fn export []{ alias:export }
|
||||
|
||||
|
||||
|
@ -1,3 +1,13 @@
|
||||
#use github.com/zzamboni/elvish-completions/builtins
|
||||
use github.com/zzamboni/elvish-completions/cd
|
||||
use github.com/zzamboni/elvish-completions/git
|
||||
git:git-command = hub
|
||||
git:git-completions[checkout] = [ { git:MODIFIED; git:BRANCHES &all } ... ]
|
||||
git:init
|
||||
#use github.com/zzamboni/elvish-completions/ssh
|
||||
|
||||
use github.com/xiaq/edit.elv/compl/go
|
||||
|
||||
use ./completion/arc
|
||||
use ./completion/archiver
|
||||
use ./completion/desarchiver
|
||||
@ -6,3 +16,4 @@ use ./completion/mpv
|
||||
use ./completion/pacman
|
||||
use ./completion/ssh
|
||||
use ./completion/sudo
|
||||
use ./completion/use
|
||||
|
@ -14,13 +14,13 @@ extensions = [ tar bz2 zip gz lz4 sz xz zst rar ]
|
||||
fn -comp-commands { all $commands }
|
||||
|
||||
fn -comp-archive-files [m]{
|
||||
local:type = (condition:set (eq $m '') prefix deep-prefix)
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m $@extensions
|
||||
}
|
||||
|
||||
fn -comp-inline-files [archive]{
|
||||
try {
|
||||
e:arc ls $archive | eawk [_ @argv]{ put $argv[-1] }
|
||||
arc ls $archive | eawk [_ @argv]{ put $argv[-1] }
|
||||
} except e {
|
||||
nop
|
||||
}
|
||||
@ -46,3 +46,4 @@ fn complete [@argv]{
|
||||
}
|
||||
|
||||
edit:completion:arg-completer[arc] = $complete~
|
||||
|
||||
|
@ -27,3 +27,4 @@ fn complete [@argv]{
|
||||
}
|
||||
|
||||
edit:completion:arg-completer[archiver] = $complete~
|
||||
|
||||
|
@ -5,7 +5,7 @@ extensions = [ tar bz2 zip gz lz4 sz xz zst rar ]
|
||||
|
||||
fn complete [@argv]{
|
||||
local:m = $argv[-1]
|
||||
local:type = (condition:set (eq $m '') prefix deep-prefix)
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m $@extensions
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ extensions = [
|
||||
]
|
||||
|
||||
fn -files [m]{
|
||||
local:type = (condition:set (eq $m '') prefix deep-prefix)
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m $@extensions
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ fn -repo-packages {
|
||||
}
|
||||
|
||||
fn -downloaded-packages [m]{
|
||||
local:type = (condition:set (eq $m '') prefix deep-prefix)
|
||||
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
||||
file:match-extensions &type=$type $m tar.zst tar.xz tar.gz tar.bz2
|
||||
}
|
||||
|
||||
|
@ -6,246 +6,101 @@ use moi/util/ip
|
||||
use moi/util/list
|
||||
use moi/util/map
|
||||
use moi/util/option
|
||||
|
||||
|
||||
options-ssh = [ 1 2 4 6 A D f g I i L l m o v a b C c e F k N n p q R s T t X x ]
|
||||
options-scp = [ 3 4 6 B C p q r v c F i l o P S ]
|
||||
|
||||
fn -init-hosts {
|
||||
local:result = [&]
|
||||
cat /etc/hosts | peach $str:trim-space~ | peach [l]{
|
||||
local:l = $l
|
||||
if (and (not-eq $l '') (not-eq $l[0] '#')) {
|
||||
put $l
|
||||
}
|
||||
} | eawk [_ ip @domains]{
|
||||
if (ip:is-ip $ip) {
|
||||
put [$ip $domains]
|
||||
}
|
||||
} | peach [e]{
|
||||
local:ip local:domains = $@e
|
||||
if (ip:is-ipv6 $ip) {
|
||||
ip = (ip:short6 $ip)
|
||||
}
|
||||
each [d]{
|
||||
if (eq $d[0] '#') {
|
||||
break
|
||||
}
|
||||
put [$ip $d]
|
||||
} $domains
|
||||
} | each [e]{
|
||||
local:ip local:d = $@e
|
||||
local:ipd = (map:value-of $result $ip &default=[&])
|
||||
ipd[$d] = $nil
|
||||
result[$ip] = $ipd
|
||||
}
|
||||
put $result
|
||||
}
|
||||
names = [
|
||||
benjamin
|
||||
luence
|
||||
]
|
||||
|
||||
fn -init-known-hosts {
|
||||
local:khosts = [&22=[&]]
|
||||
fn -kh {
|
||||
cat ~/.ssh/known_hosts | peach [l]{
|
||||
put [(str:split ' ' $l)]
|
||||
} | peach [e]{
|
||||
local:domains @local:id = $@e
|
||||
id = (str:join ' ' $id)
|
||||
str:split ',' $domains | peach [d]{
|
||||
local:d = $d
|
||||
local:port = 22
|
||||
if (eq $d[0] '[') {
|
||||
local:i = (str:index $d ']')
|
||||
port = $d[(+ $i 2):]
|
||||
d = $d[1:$i]
|
||||
}
|
||||
put [$id $d $port]
|
||||
}
|
||||
} | each [e]{
|
||||
local:id local:d local:port = $@e
|
||||
local:pdomains = (map:value-of $khosts $port &default=[&])
|
||||
local:idomains = (map:value-of $pdomains $id &default=[&])
|
||||
idomains[$d] = $nil
|
||||
pdomains[$id] = $idomains
|
||||
khosts[$port] = $pdomains
|
||||
local:domains @_ = $@e
|
||||
str:split ',' $domains
|
||||
}
|
||||
local:result = [&22=[&]]
|
||||
keys $khosts | each [port]{
|
||||
local:pdomains = (map:value-of $result $port &default=[&])
|
||||
keys $khosts[$port] | peach [id]{
|
||||
local:id = $id
|
||||
local:domains = [(keys $khosts[$port][$id])]
|
||||
if (list:contains-not $ip:is-ip~ $domains) {
|
||||
list:filter-not $ip:is-ip~ $domains | peach [d]{ pdomains[$d] = $nil }
|
||||
} else {
|
||||
peach [d]{ pdomains[$d] = $nil } $domains
|
||||
}
|
||||
}
|
||||
result[$port] = $pdomains
|
||||
}
|
||||
put $result
|
||||
}
|
||||
|
||||
|
||||
fn -init-history {
|
||||
local:history = [&]
|
||||
edit:command-history | peach [e]{
|
||||
put $e[cmd]
|
||||
} | peach [h]{
|
||||
if (re:match '^(ssh|scp)\ .+' $h) {
|
||||
history[$h] = $nil
|
||||
}
|
||||
fn -port [cmd @argv]{
|
||||
local:o = (condition:cset (eq $cmd 'ssh') '-p' '-P')
|
||||
local:margs = (option:map $argv)
|
||||
local:p = (map:value-of $margs $o &default=[])
|
||||
if (list:empty $p) {
|
||||
put 22
|
||||
} else {
|
||||
put $p[-1]
|
||||
}
|
||||
local:result = [&22=[&]]
|
||||
keys $history | peach [h]{
|
||||
local:h = $h
|
||||
put [(re:split '[ \t]+' $h)]
|
||||
} | peach [e]{
|
||||
local:cmd @local:argv = $@e
|
||||
local:port local:name local:domain = 22 '' ''
|
||||
local:c = (- (count $argv) 1)
|
||||
list:loop [i arg]{
|
||||
if (and (< $i $c) (or (and (eq $cmd ssh) (eq $arg -p)) (eq $arg -P))) {
|
||||
port = $argv[(+ $i 1)]
|
||||
} else {
|
||||
local:nd = [(str:split '@' $arg)]
|
||||
if (== (count $nd) 2) {
|
||||
name = $nd[0]
|
||||
domain @_ = (str:split ':' $nd[1])
|
||||
break
|
||||
}
|
||||
}
|
||||
} $argv
|
||||
if (and (not-eq $name '') (not-eq $domain '')) {
|
||||
put [$port $name $domain]
|
||||
}
|
||||
} | each [e]{
|
||||
local:port local:name local:domain = $@e
|
||||
local:pnames = (map:value-of $result $port &default=[&])
|
||||
local:domains = (map:value-of $pnames $name &default=[&])
|
||||
domains[$domain] = $nil
|
||||
pnames[$name] = $domains
|
||||
result[$port] = $pnames
|
||||
}
|
||||
put $result
|
||||
}
|
||||
|
||||
combinaisons = [&]
|
||||
fn -complete-names []{ each [n]{ put $n'@' } $names }
|
||||
|
||||
fn init {
|
||||
local:hosts local:known-hosts local:history = [] [] []
|
||||
peach [f]{ $f } [
|
||||
{ hosts = (-init-hosts) }
|
||||
{ known-hosts = (-init-known-hosts) }
|
||||
{ history = (-init-history) }
|
||||
]
|
||||
combinaisons = $history
|
||||
keys $known-hosts | peach [port]{
|
||||
local:port = $port
|
||||
local:pdomains = $known-hosts[$port]
|
||||
keys $pdomains | peach [domain]{
|
||||
local:domain = $domain
|
||||
if (and (ip:is-ip $domain) (has-key $hosts $domain)) {
|
||||
del pdomains[$domain]
|
||||
keys $hosts[$domain] | peach [d]{
|
||||
local:d = $d
|
||||
pdomains[$d] = $nil
|
||||
}
|
||||
}
|
||||
fn -complete-domains [name hosts]{
|
||||
each [h]{
|
||||
put $name@$h
|
||||
} $hosts
|
||||
}
|
||||
|
||||
fn -complete-remote-dir [port address dir]{
|
||||
try {
|
||||
ssh -p $port $address 'ls '$dir | each [f]{
|
||||
put $address':'$dir$f
|
||||
}
|
||||
if (> (keys $pdomains | count) 0) {
|
||||
if (has-key $history $port) {
|
||||
local:phist = $history[$port]
|
||||
local:dhist = (keys $phist | peach [name]{ keys $phist[$name] } | map:to-set)
|
||||
local:dknown = [&]
|
||||
keys $pdomains | peach [domain]{
|
||||
local:domain = $domain
|
||||
if (not (has-key $dhist $domain)) {
|
||||
dknown[$domain] = $nil
|
||||
} except e {
|
||||
}
|
||||
}
|
||||
|
||||
fn -complete-args [hosts cmd @argv]{
|
||||
local:arg = $argv[-1]
|
||||
local:i = (str:index $arg @)
|
||||
if (< $i 0) {
|
||||
-complete-names
|
||||
all $hosts
|
||||
if (eq $cmd scp) {
|
||||
edit:complete-filename $cmd $@argv
|
||||
}
|
||||
return
|
||||
}
|
||||
local:n local:h = $arg[..$i] $arg[(+ $i 1)..]
|
||||
if (eq $cmd scp) {
|
||||
i = (str:index $h :)
|
||||
if (>= $i 0) {
|
||||
local:d = $h[(+ $i 1)..]
|
||||
h = $h[..$i]
|
||||
if (list:includes $h $hosts) {
|
||||
local:p = (-port $cmd @argv)
|
||||
local:e = [ (str:split / $d) ]
|
||||
if (not-eq $e[-1] '') {
|
||||
d = (str:join / $e[..-1])
|
||||
if (eq $d '') {
|
||||
d = /
|
||||
}
|
||||
}
|
||||
if (> (keys $dknown | count) 0) {
|
||||
combinaisons[$port] = (assoc $phist '' $dknown)
|
||||
} else {
|
||||
combinaisons[$port] = [&''=$dknown]
|
||||
}
|
||||
} else {
|
||||
combinaisons[$port] = [&''=$pdomains]
|
||||
-complete-remote-dir $p $n@$h $d
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn -known-ports { keys $combinaisons }
|
||||
|
||||
fn -known-names [&port=22]{
|
||||
keys (map:value-of $combinaisons $port &default=[&]) | list:filter [n]{ not-eq $n '' }
|
||||
}
|
||||
|
||||
fn -known-hosts [&port=22 &name=$false]{
|
||||
local:phosts = (map:value-of $combinaisons $port &default=[&])
|
||||
if $name {
|
||||
keys (map:value-of $phosts $name &default=[&])
|
||||
} else {
|
||||
keys (keys $phosts | peach [name]{
|
||||
local:name = $name
|
||||
keys $phosts[$name]
|
||||
} | map:to-set)
|
||||
}
|
||||
}
|
||||
|
||||
fn -port [&cmd=ssh @argv]{
|
||||
o = (condition:set (eq $cmd 'ssh') '-p' '-P')
|
||||
margs = (option:map $argv)
|
||||
map:value-of $margs $o &default=[]
|
||||
}
|
||||
|
||||
fn -complete-options [list @args]{ each [o]{ put -$o } $list }
|
||||
|
||||
fn -complete-args [cmd @argv]{
|
||||
local:port = (-port $cmd $@argv)
|
||||
if (list:empty $port) {
|
||||
port = 22
|
||||
} else {
|
||||
port = $port[-1]
|
||||
}
|
||||
local:larg = $argv[-1]
|
||||
local:name @local:host = (str:split '@' $larg)
|
||||
if (list:empty $host) {
|
||||
-known-names &port=$port | each [n]{ put $n'@' }
|
||||
if (eq $cmd 'scp') {
|
||||
file:match-files $larg
|
||||
}
|
||||
} else {
|
||||
host @_ = (str:split ':' $host[0])
|
||||
local:check = [h]{ has-prefix $h $host }
|
||||
local:khosts = [(-known-hosts &port=$port &name=$name)]
|
||||
if (not (list:contains $check $khosts)) {
|
||||
khosts = [(-known-hosts &port=$port)]
|
||||
if (not (list:contains $check $khosts)) {
|
||||
khosts = [(-known-hosts)]
|
||||
}
|
||||
}
|
||||
each [h]{ put $name'@'$h } $khosts
|
||||
all $khosts
|
||||
}
|
||||
-complete-domains $n $hosts
|
||||
}
|
||||
|
||||
fn complete [@argv]{
|
||||
if (keys $combinaisons | list:empty) {
|
||||
init
|
||||
}
|
||||
@hosts = (-kh)
|
||||
local:cmd = $argv[0]
|
||||
local:is-ssh = (eq $cmd ssh)
|
||||
local:po = (condition:set $is-ssh -p -P)
|
||||
local:po = (condition:cset $is-ssh -p -P)
|
||||
if (<= (count $argv) 2) {
|
||||
-complete-options (condition:set $is-ssh $options-ssh $options-scp)
|
||||
-complete-args $@argv
|
||||
all (condition:cset $is-ssh $options-ssh $options-scp)
|
||||
-complete-args $hosts $@argv
|
||||
} elif (eq $argv[-2] $po) {
|
||||
-known-ports
|
||||
put 22
|
||||
} else {
|
||||
-complete-args $@argv
|
||||
-complete-args $hosts $@argv
|
||||
}
|
||||
}
|
||||
|
||||
edit:completion:arg-completer[scp] = $complete~
|
||||
edit:completion:arg-completer[ssh] = $complete~
|
||||
|
||||
init&
|
||||
|
@ -1,7 +0,0 @@
|
||||
use moi/util/condition
|
||||
use moi/util/file
|
||||
use moi/util/ip
|
||||
use moi/util/list
|
||||
use moi/util/map
|
||||
use moi/util/number
|
||||
use moi/util/option
|
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
fn set [c t f]{
|
||||
fn cset [c t f]{
|
||||
if $c {
|
||||
put $t
|
||||
} else {
|
||||
@ -7,11 +7,11 @@ fn set [c t f]{
|
||||
}
|
||||
|
||||
fn mset [c t f]{
|
||||
all (set $c $t $f)
|
||||
all (cset $c $t $f)
|
||||
}
|
||||
|
||||
fn call [c t f @argv]{
|
||||
local:v = (set $c $t $f)
|
||||
local:v = (cset $c $t $f)
|
||||
if (is (kind-of $v) fn) {
|
||||
$v $@argv
|
||||
} else {
|
||||
|
@ -1,5 +1,9 @@
|
||||
use str
|
||||
use ./list
|
||||
use ./map
|
||||
|
||||
search-type = [
|
||||
&exact= [m]{ e:ls $m 2>/dev/null }
|
||||
&exact= [m]{ ls $m 2>/dev/null }
|
||||
&match= [m]{ put *$m* }
|
||||
&prefix= [m]{ put $m* }
|
||||
&suffix= [m]{ put *$m }
|
||||
@ -9,7 +13,6 @@ search-type = [
|
||||
]
|
||||
|
||||
fn -less [f1 f2]{
|
||||
use str
|
||||
local:fl1 local:fl2 = (str:to-lower $f1) (str:to-lower $f2)
|
||||
local:c = (str:compare $fl1 $fl2)
|
||||
if (== $c 0) {
|
||||
@ -27,11 +30,9 @@ fn -get-results [sort result]{
|
||||
}
|
||||
|
||||
fn -search [&sort=$false &type=exact @motive]{
|
||||
use ./list
|
||||
local:f = $search-type[$type]
|
||||
local:result = [&]
|
||||
if (list:empty $motive) {
|
||||
use ./map
|
||||
result = (put * | map:to-set)
|
||||
} else {
|
||||
peach [m]{
|
||||
@ -50,11 +51,10 @@ fn -search [&sort=$false &type=exact @motive]{
|
||||
fn match-files [&sort=$false &type=prefix @motive]{ -search &sort=$sort &type=$type $@motive }
|
||||
|
||||
fn match-extensions [&sort=$false &type=deep-prefix motive @extensions]{
|
||||
use ./list
|
||||
result = [&]
|
||||
-search &type=$type $motive | peach [f]{
|
||||
local:f = $f
|
||||
if (list:contains [e]{ has-suffix $f .$e } $extensions) {
|
||||
if (list:contains [e]{ str:has-suffix $f .$e } $extensions) {
|
||||
result[$f] = $nil
|
||||
}
|
||||
}
|
||||
|
@ -40,14 +40,13 @@ fn -long-part6 [p]{
|
||||
|
||||
fn -middle-part6 [p]{
|
||||
while (and (> (count $p) 1) (eq $p[0] 0)) {
|
||||
p = $p[1:]
|
||||
p = $p[1..]
|
||||
}
|
||||
put $p
|
||||
}
|
||||
|
||||
fn -find-max0 [parts]{
|
||||
use ./list
|
||||
use ./condition
|
||||
local:idx local:s = -1 1
|
||||
local:ci local:cs local:f = -1 0 $false
|
||||
list:loop [i p]{
|
||||
@ -78,7 +77,7 @@ fn long6 [ip]{
|
||||
if (> $c 0) {
|
||||
local:i = (str:index $ip '::')
|
||||
local:z = (repeat $c ':' | str:join '')
|
||||
ip = (str:join '' [$ip[:$i] $z $ip[{$i}:]])
|
||||
ip = (str:join '' [$ip[..$i] $z $ip[{$i}..]])
|
||||
}
|
||||
str:split ':' $ip | each $-long-part6~ | str:join ':'
|
||||
}
|
||||
@ -91,7 +90,7 @@ fn short6 [ip]{
|
||||
local:parts = [(str:split ':' (middle6 $ip))]
|
||||
local:i local:s = (-find-max0 $parts)
|
||||
if (>= $i 0) {
|
||||
local:left local:right = $parts[:$i] $parts[(+ $i $s):]
|
||||
local:left local:right = $parts[..$i] $parts[(+ $i $s)..]
|
||||
if (== (count $left) 0) {
|
||||
left = ['']
|
||||
}
|
||||
@ -111,7 +110,7 @@ fn -cmp [e1 e2]{
|
||||
local:c = 0
|
||||
list:loop [i p1]{
|
||||
local:p2 = $e2[$i]
|
||||
c = (condition:set (< $p1 $p2) -1 (condition:set (> $p1 $p2) 1 0))
|
||||
c = (condition:cset (< $p1 $p2) -1 (condition:cset (> $p1 $p2) 1 0))
|
||||
if (!= $c 0) {
|
||||
break
|
||||
}
|
||||
@ -149,6 +148,6 @@ fn cmp [ip1 ip2]{
|
||||
put -1
|
||||
}
|
||||
} else {
|
||||
fali 'Not an IP: '$ip1' → '$ip2
|
||||
fail 'Not an IP: '$ip1' → '$ip2
|
||||
}
|
||||
}
|
||||
|
@ -1,230 +1,23 @@
|
||||
use ./condition
|
||||
|
||||
fn -i [&reverse=false i c]{
|
||||
if (and (== $c 0) (or (== $i 0) ($i -1))) {
|
||||
put 0
|
||||
return
|
||||
}
|
||||
if (< $i 0) {
|
||||
i = (+ $c $i)
|
||||
}
|
||||
if (or (and (>= $i 0) (< $i $c)) (and (== $i -1) $reverse) (and (== $i $c) (not $reverse))) {
|
||||
put $i
|
||||
} else {
|
||||
fail 'Index out of range'
|
||||
}
|
||||
}
|
||||
fn -indexes [&from=$false &step=1 l]{
|
||||
if (== $step 0) {
|
||||
fail 'Step must be ≠ 0'
|
||||
}
|
||||
local:c local:r = (count $l) (< $step 0)
|
||||
if (not $from) {
|
||||
if $r {
|
||||
range &step=$step[1:] $c | each [i]{ - $c $i 1 }
|
||||
} else {
|
||||
range &step=$step $c
|
||||
}
|
||||
} else {
|
||||
from = (-i &reverse=$r $from $c)
|
||||
if $r {
|
||||
c = (+ $from 1)
|
||||
range &step=$step[1:] $c | each [i]{ - $c $i 1 }
|
||||
} else {
|
||||
range &step=$step $from $c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn -loop [&from=$false &step=1 &end=$false cb l]{
|
||||
if (not $end) {
|
||||
-indexes &from=$from &step=$step $l | each [i]{
|
||||
put [$i $l[$i]]
|
||||
} | each [e]{
|
||||
$cb $@e
|
||||
}
|
||||
} else {
|
||||
-indexes &from=$from &step=$step $l | each [i]{
|
||||
put [$i $l[$i]]
|
||||
} | each [e]{
|
||||
local:i local:v = $@e
|
||||
if ($end $i $v) {
|
||||
break
|
||||
}
|
||||
$cb $i $v
|
||||
}
|
||||
}
|
||||
}
|
||||
fn -ploop [&from=$false &step=1 cb l]{
|
||||
-indexes &from=$from &step=$step $l | peach [i]{
|
||||
put [$i $l[$i]]
|
||||
} | peach [e]{
|
||||
$cb $@e
|
||||
}
|
||||
}
|
||||
|
||||
fn -reverse [l]{
|
||||
-indexes &step=-1 $l | each [i]{ put $l[$i] }
|
||||
}
|
||||
fn -reach [cb l]{
|
||||
-reverse $l | each [v]{ $cb $v }
|
||||
}
|
||||
|
||||
fn -empty [l]{ eq (count $l) 0 }
|
||||
|
||||
fn -filter [cb l]{
|
||||
each [v]{
|
||||
if ($cb $v) {
|
||||
put $v
|
||||
}
|
||||
} $l
|
||||
}
|
||||
fn -first [&from=$false &reverse=$false cb l]{
|
||||
local:f = [v]{
|
||||
if ($cb $v) {
|
||||
put $v
|
||||
break
|
||||
}
|
||||
}
|
||||
if $reverse {
|
||||
if $from {
|
||||
local:end = (-i $from (count $l))
|
||||
-reach $f $l[:(+ $end 1)]
|
||||
} else {
|
||||
-reach $f $l
|
||||
}
|
||||
} else {
|
||||
if $from {
|
||||
from = (-i $from (count $l))
|
||||
drop $from $l | each $f
|
||||
} else {
|
||||
each $f $l
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn -filter-index [cb l]{
|
||||
-loop [i v]{
|
||||
if ($cb $v) {
|
||||
put $i
|
||||
}
|
||||
} $l
|
||||
}
|
||||
fn -first-index [&from=$false &reverse=$false cb l]{
|
||||
local:idx = -1
|
||||
-loop &from=$from &step=(condition:set $reverse -1 1) [i v]{
|
||||
if ($cb $v) {
|
||||
idx = $i
|
||||
break
|
||||
}
|
||||
} $l
|
||||
put $idx
|
||||
}
|
||||
|
||||
fn -search [cb l]{
|
||||
-loop [i v]{
|
||||
if ($cb $i $v) {
|
||||
put $v
|
||||
}
|
||||
} $l
|
||||
}
|
||||
fn -search-first [&from=$false &reverse=$false cb l]{
|
||||
-loop &from=$from &step=(condition:set $reverse -1 1) [i v]{
|
||||
if ($cb $i $v) {
|
||||
put $v
|
||||
break
|
||||
}
|
||||
} $l
|
||||
}
|
||||
|
||||
fn -search-index [cb l]{
|
||||
-loop [i v]{
|
||||
if ($cb $i $v) {
|
||||
put $i
|
||||
}
|
||||
} $l
|
||||
}
|
||||
fn -search-first-index [&from=$false &reverse=$false cb l]{
|
||||
local:idx = -1
|
||||
-loop &from=$from &step=(condition:set $reverse -1 1) [i v]{
|
||||
if ($cb $i $v) {
|
||||
idx = $i
|
||||
break
|
||||
}
|
||||
}
|
||||
put $idx
|
||||
}
|
||||
|
||||
fn -contains [cb l]{
|
||||
local:e = $false
|
||||
each [v]{
|
||||
if ($cb $v) {
|
||||
e = $true
|
||||
break
|
||||
}
|
||||
} $l
|
||||
put $e
|
||||
}
|
||||
fn -exists [cb l]{
|
||||
local:e = $false
|
||||
-loop [i v]{
|
||||
if ($cb $i $v) {
|
||||
e = $true
|
||||
break
|
||||
}
|
||||
} $l
|
||||
put $e
|
||||
}
|
||||
|
||||
fn -remove-duplicate [l]{
|
||||
local:done = [&]
|
||||
each [v]{
|
||||
put [&v=$v &e=(has-key $done $v)]
|
||||
done[$v] = $nil
|
||||
} $l | each [v]{
|
||||
assoc $v k (not $v[e])
|
||||
} | each [v]{
|
||||
if $v[k] {
|
||||
put $v[v]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn -premove-duplicate [l]{
|
||||
local:done= [&]
|
||||
peach [v]{
|
||||
local:v = $v
|
||||
done[$v] = $nil
|
||||
}
|
||||
keys $done
|
||||
}
|
||||
|
||||
fn -swap [i j l]{
|
||||
local:c = (count $l)
|
||||
i j = (-i $i $c) (-i $j $c)
|
||||
if (or (eq $i $c) (eq $j $c)) {
|
||||
fail 'Index out of range'
|
||||
}
|
||||
if (eq $i $j) {
|
||||
all $l
|
||||
} else {
|
||||
i j = (condition:mset (< $i $j) [$i $j] [$j $i])
|
||||
take $i $l
|
||||
put $l[j]
|
||||
all $l[(+ $i 1):$j]
|
||||
put $l[$i]
|
||||
drop (+ $j 1) $l
|
||||
}
|
||||
}
|
||||
use builtin
|
||||
use str
|
||||
|
||||
fn -p [@argv]{
|
||||
local:c = (count $argv)
|
||||
if (eq $c 0) {
|
||||
put [(all)]
|
||||
} elif (eq $c 1) {
|
||||
if (== $c 0) {
|
||||
put [ (all) ]
|
||||
} elif (== $c 1) {
|
||||
put $argv[0]
|
||||
} else {
|
||||
fail '0 or 1 argument needed'
|
||||
fail '0 or 1 argument needed given '$c' arguments: ['(each [e]{ put '"'$e'"' } $argv | str:join ', ')']'
|
||||
}
|
||||
}
|
||||
|
||||
fn -r [step begin end]{
|
||||
if (> $step 0) {
|
||||
builtin:range &step=$step $begin (+ $end 1)
|
||||
} else {
|
||||
local:d = (+ $begin $end)
|
||||
builtin:range &step=(* $step -1) $end (+ $begin 1) | each [e]{ - $d $e }
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,38 +29,214 @@ fn to-list [@argv]{
|
||||
}
|
||||
}
|
||||
|
||||
fn indexes [&from=$false &step=1 @argv]{ -indexes &from=$from &step=1 (-p $@argv) }
|
||||
fn range [&step=1 b @r]{
|
||||
if (== $step 0) {
|
||||
fail 'bad value: step must be positive, but is 0'
|
||||
}
|
||||
local:c = (count $r)
|
||||
if (> $c 1) {
|
||||
fail 'usage: list:range &step=1 begin? end'
|
||||
}
|
||||
local:e = 0
|
||||
if (== $c 0) {
|
||||
if (> $step 0) {
|
||||
b e = $e $b
|
||||
}
|
||||
} else {
|
||||
e = $r[0]
|
||||
}
|
||||
-r $step $b $e
|
||||
}
|
||||
|
||||
fn loop [&from=$false &step=1 &end=$false cb @argv]{ -loop &from=$from &step=$step &end=$end $cb (-p $@argv) }
|
||||
fn rloop [&end=$false cb @argv]{ loop &step=-1 &end=$end $cb $@argv }
|
||||
fn ploop [&from=$false &step=1 cb @argv]{ -ploop &from=$from &step=$step $cb (-p $@argv) }
|
||||
fn indexes [&from=$false &step=1 @argv]{
|
||||
if (== $step 0) {
|
||||
fail 'bad value: step must be positive, but is 0'
|
||||
}
|
||||
local:l = (-p $@argv)
|
||||
local:c = (count $l)
|
||||
if (not $from) {
|
||||
range &step=$step (- $c 1)
|
||||
} else {
|
||||
if (< $from 0) {
|
||||
from = (+ $c $from)
|
||||
}
|
||||
if (> $step 0) {
|
||||
if (< $from 0) {
|
||||
from = 0
|
||||
}
|
||||
range &step=$step $from (- $c 1)
|
||||
} else {
|
||||
if (>= $from $c) {
|
||||
from = (- $c 1)
|
||||
}
|
||||
range &step=$step $from 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn reverse [@argv]{ -reverse (-p $@argv) }
|
||||
fn reach [cb @argv]{ -reach $cb (-p $@argv) }
|
||||
fn -for [&from=$false &step=1 @argv]{
|
||||
local:l = (-p $@argv)
|
||||
indexes &from=$from &step=$step $l | each [i]{ put [ $i $l[$i] ] }
|
||||
}
|
||||
|
||||
fn empty [@argv]{ -empty (-p $@argv) }
|
||||
fn loop [&from=$false &step=1 &end=$false cb @argv]{
|
||||
if (not $end) {
|
||||
-for &from=$from &step=$step $@argv | each [e]{ $cb $@e }
|
||||
} else {
|
||||
-for &from=$from &step=$step $@argv | each [e]{
|
||||
local:i local:v = $@e
|
||||
if ($end $i $v) {
|
||||
break
|
||||
}
|
||||
$cb $i $v
|
||||
}
|
||||
}
|
||||
}
|
||||
fn ploop [&from=$false &step=1 cb @argv]{
|
||||
-for &from=$from &step=$step $@argv | peach [e]{ $cb $@e }
|
||||
}
|
||||
fn reverse [@argv]{ loop &step=-1 [_ e]{ put $e } $@argv }
|
||||
fn reach [cb @argv]{ reverse $@argv | each [e]{ cb $e } }
|
||||
|
||||
fn empty [@argv]{ == (count (-p $@argv)) 0 }
|
||||
fn not-empty [@argv]{ not (empty $@argv) }
|
||||
|
||||
fn filter [cb @argv]{ -filter $cb (-p $@argv) }
|
||||
fn filter [cb @argv]{
|
||||
each [v]{
|
||||
if ($cb $v) {
|
||||
put $v
|
||||
}
|
||||
} (-p $@argv)
|
||||
}
|
||||
fn filter-not [cb @argv]{ filter [v]{ not ($cb $v) } $@argv }
|
||||
fn first [&from=$false &reverse=$false cb @argv]{ -first &from=$from &reverse=$reverse $cb (-p $@argv) }
|
||||
fn first [&from=$false &reverse=$false cb @argv]{
|
||||
local:f = [v]{
|
||||
if ($cb $v) {
|
||||
put $v
|
||||
break
|
||||
}
|
||||
}
|
||||
local:l = (-p $@argv)
|
||||
if (not $from) {
|
||||
if $reverse {
|
||||
reach $f $l
|
||||
} else {
|
||||
each $f $l
|
||||
}
|
||||
} else {
|
||||
local:c = (count $l)
|
||||
if (< $from 0) {
|
||||
from = (+ $c $from)
|
||||
}
|
||||
if $reverse {
|
||||
local:e = (+ $from 1)
|
||||
if (> $e $c) {
|
||||
e = $c
|
||||
} elif (< $e 0) {
|
||||
e = 0
|
||||
}
|
||||
reach $f $l[..$e]
|
||||
} else {
|
||||
local:b = $from
|
||||
if (> $b $c) {
|
||||
b = $c
|
||||
} elif (< $b 0) {
|
||||
b = 0
|
||||
}
|
||||
each $f $l[$b..]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn filter-index [cb @argv]{ -filter-index $cb (-p $@argv) }
|
||||
fn filter-index [cb @argv]{
|
||||
loop [i v]{
|
||||
if ($cb $v) {
|
||||
put $i
|
||||
}
|
||||
} $@argv
|
||||
}
|
||||
fn filter-index-not [cb @argv]{ filter-index [v]{ not ($cb $v) } $@argv }
|
||||
fn first-index [&from=$false &reverse=$false cb @argv]{ -first-index &from=$from &reverse=$reverse $cb (-p $@argv) }
|
||||
fn first-index [&from=$false &reverse=$false cb @argv]{
|
||||
local:idx = -1
|
||||
local:step = 1
|
||||
if $reverse {
|
||||
step = -1
|
||||
}
|
||||
loop &from=$from &step=$step [i v]{
|
||||
if ($cb $v) {
|
||||
idx = $i
|
||||
break
|
||||
}
|
||||
} $@argv
|
||||
put $idx
|
||||
}
|
||||
|
||||
fn search [cb @argv]{ -search $cb (-p $@argv) }
|
||||
fn search [cb @argv]{
|
||||
loop [i v]{
|
||||
if ($cb $i $v) {
|
||||
put $v
|
||||
}
|
||||
} $@argv
|
||||
}
|
||||
fn search-not [cb @argv]{ search [i v]{ not ($cb $i $v) } $@argv }
|
||||
fn search-first [&from=$false &reverse=$false cb @argv]{ -search-first &from=$from &reverse=$reverse $cb (-p $@argv) }
|
||||
fn search-first [&from=$false &reverse=$false cb @argv]{
|
||||
local:step = 1
|
||||
if $reverse {
|
||||
step = -1
|
||||
}
|
||||
loop &from=$from &step=$step [i v]{
|
||||
if ($cb $i $v) {
|
||||
put $v
|
||||
break
|
||||
}
|
||||
} $@argv
|
||||
}
|
||||
|
||||
fn search-index [cb @argv]{ -search-index $cb (-p $@argv) }
|
||||
fn search-index [cb @argv]{
|
||||
loop [i v]{
|
||||
if ($cb $i $v) {
|
||||
put $i
|
||||
}
|
||||
} $@argv
|
||||
}
|
||||
fn search-index-not [cb @argv]{ search-index [i v]{ not ($cb $i $v) } $@argv }
|
||||
fn search-first-index [&from=$false &reverse=$false cb @argv]{ -search-first-index &from=$from &reverse=$reverse $cb (-p $@argv) }
|
||||
fn search-first-index [&from=$false &reverse=$false cb @argv]{
|
||||
local:idx = -1
|
||||
local:step = 1
|
||||
if $reverse {
|
||||
step = -1
|
||||
}
|
||||
loop &from=$from &step=$step [i v]{
|
||||
if ($cb $i $v) {
|
||||
idx = $i
|
||||
break
|
||||
}
|
||||
} $@argv
|
||||
put $idx
|
||||
}
|
||||
|
||||
fn contains [cb @argv]{ -contains $cb (-p $@argv) }
|
||||
fn contains [cb @argv]{
|
||||
local:e = $false
|
||||
each [v]{
|
||||
if ($cb $v) {
|
||||
e = $true
|
||||
break
|
||||
}
|
||||
} (-p $@argv)
|
||||
put $e
|
||||
}
|
||||
fn contains-not [cb @argv]{ contains [v]{ not ($cb $v) } $@argv }
|
||||
|
||||
fn exists [cb @argv]{ -exists $cb (-p $@argv) }
|
||||
fn exists [cb @argv]{
|
||||
local:e = $false
|
||||
loop [i v]{
|
||||
if ($cb $i $v) {
|
||||
e = $true
|
||||
break
|
||||
}
|
||||
} $@argv
|
||||
put $e
|
||||
}
|
||||
fn exists-not [cb @argv]{ exists [i v]{ $cb $i $v } $@argv }
|
||||
|
||||
fn includes [v @argv]{ contains [e]{ is $v $e } $@argv }
|
||||
@ -278,24 +247,46 @@ fn reduce [v cb @argv]{
|
||||
put $v
|
||||
}
|
||||
|
||||
fn remove-duplicate [@argv]{ -remove-duplicate (-p $@argv) }
|
||||
fn premove-duplicate [@argv]{ -premove-duplicate (-p $@argv) }
|
||||
fn remove-duplicate [@argv]{
|
||||
local:done = [&]
|
||||
each [v]{
|
||||
put [&v=$v &e=(has-key $done $v)]
|
||||
done[$v] = $nil
|
||||
} (-p $@argv) | each [v]{
|
||||
assoc $v k (not $v[e])
|
||||
} | each [v]{
|
||||
if $v[k] {
|
||||
put $v[v]
|
||||
}
|
||||
}
|
||||
}
|
||||
fn premove-duplicate [@argv]{
|
||||
local:done= [&]
|
||||
peach [v]{
|
||||
local:v = $v
|
||||
done[$v] = $nil
|
||||
} (-p $@argv)
|
||||
keys $done
|
||||
}
|
||||
|
||||
fn swap [i j @argv]{ -swap $i $j (-p $@argv) }
|
||||
|
||||
fn -s1 [cb l e]{
|
||||
fn swap [i j @argv]{
|
||||
local:l = (-p $@argv)
|
||||
local:c = (count $l)
|
||||
local:i = (first-index [v]{ $cb $e $v } $l)
|
||||
if (eq $i 0) {
|
||||
put $e
|
||||
i j = (-i $i $c) (-i $j $c)
|
||||
if (or (== $i $c) (== $j $c)) {
|
||||
fail 'Index out of range'
|
||||
}
|
||||
if (== $i $j) {
|
||||
all $l
|
||||
} elif (< $i 0) {
|
||||
all $l
|
||||
put $e
|
||||
} else {
|
||||
all $l[:$i]
|
||||
put $e
|
||||
all $l[{$i}:]
|
||||
if (> $i $j) {
|
||||
i j = $j $i
|
||||
}
|
||||
take $i $l
|
||||
put $l[j]
|
||||
all $l[(+ $i 1)..$j]
|
||||
put $l[$i]
|
||||
drop (+ $j 1) $l
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,9 +294,4 @@ fn less [cb]{
|
||||
local:l = [a b]{ < ($cb $a $b) 0 }
|
||||
put $l
|
||||
}
|
||||
|
||||
fn -sort [cb l]{
|
||||
order &less-than=(less $cb) $l
|
||||
}
|
||||
|
||||
fn sort [cb @argv]{ -sort $cb (-p $@argv) }
|
||||
fn sort [cb @argv]{ order &less-than=(less $cb) (-p $@argv) }
|
||||
|
@ -21,9 +21,11 @@ fn unzip [container]{
|
||||
}
|
||||
|
||||
fn zip [lkeys lvalues]{
|
||||
use ./condition
|
||||
local:ck local:cv = (count $lkeys) (count $lvalues)
|
||||
local:c = (condition:set (> $ck $cv) $cv $ck)
|
||||
local:c = $ck
|
||||
if (> $ck $cv) {
|
||||
c = $cv
|
||||
}
|
||||
local:result = [&]
|
||||
range $c | peach [i]{
|
||||
put [&k=$lkeys[$i] &i=$i]
|
||||
|
@ -1,40 +0,0 @@
|
||||
fn sign [n]{
|
||||
if (> $n 0) {
|
||||
put 1
|
||||
} elif (< $n 0) {
|
||||
put -1
|
||||
} else {
|
||||
put 0
|
||||
}
|
||||
}
|
||||
|
||||
fn negative [n]{ < $n 0 }
|
||||
fn positive [n]{ >= $n 0 }
|
||||
|
||||
fn ++ [n]{ to-string (+ $n 1) }
|
||||
fn -- [n]{ to-string (+ $n 1) }
|
||||
|
||||
|
||||
fn neg [n]{ to-string (* $n -1) }
|
||||
fn abs [n]{
|
||||
use ./condition
|
||||
condition:call (negative $n) $neg~ $put~ $n
|
||||
}
|
||||
|
||||
fn sum [@numbers]{
|
||||
use ./list
|
||||
to-string (list:reduce 0 $+~ $numbers)
|
||||
}
|
||||
|
||||
fn -minmax [t numbers]{
|
||||
if (== (count $numbers) 0) {
|
||||
return
|
||||
}
|
||||
use ./list
|
||||
use ./condition
|
||||
f = [c v]{ condition:set ($t $v $c) $v $c }
|
||||
list:reduce $numbers[0] $f $numbers[1:]
|
||||
}
|
||||
|
||||
fn min [@numbers]{ -minmax $<~ $numbers }
|
||||
fn max [@numbers]{ -minmax $>~ $numbers }
|
74
rc.elv
74
rc.elv
@ -1,63 +1,31 @@
|
||||
use github.com/muesli/elvish-libs/theme/powerline
|
||||
powerline:prompt-pwd-dir-length = 0
|
||||
powerline:timestamp-format = "%Y.%m.%d %H:%M"
|
||||
set-env BAT_PAGER 'less -RF'
|
||||
set-env EDITOR vim
|
||||
set-env VIEW 'vim -R'
|
||||
set-env CURRENT_SHELL 'elvish'
|
||||
paths = [$@paths /home/benjamin/bin /home/benjamin/Go/bin ]
|
||||
|
||||
#edit:prompt={
|
||||
# put "┌─"(styled "["(date "+%d.%m.%Y %H:%M")"]" yellow bold); put " --- "(styled "["(pwd)"]" blue bold)
|
||||
# #echo "\n"
|
||||
# put "\n└─"(styled "["(whoami)"@"(hostname) green bold);put ' > '
|
||||
# #put "┌─";edit:styled "["(date "+%d.%m.%Y %H:%M")"]" [yellow bold]; put " --- ";edit:styled "["(pwd)"]" [blue bold]
|
||||
# ##echo "\n"
|
||||
# #put "\n└─";edit:styled "["(whoami)"@"(hostname) [green bold];put ' > '
|
||||
#}
|
||||
|
||||
#use github.com/zzamboni/elvish-modules/alias
|
||||
#-exports- = (alias:export)
|
||||
|
||||
fn whichall [@a]{
|
||||
each [p]{
|
||||
each [f]{
|
||||
try {
|
||||
ll $p/$f 2>/dev/null
|
||||
} except e {
|
||||
}
|
||||
} $a
|
||||
} $paths
|
||||
{
|
||||
use moi/util/list
|
||||
if (list:includes-not /usr/local/bin $paths) {
|
||||
paths = [ $@paths /usr/local/bin ]
|
||||
}
|
||||
}
|
||||
|
||||
fn ++ [n]{ to-string (+ $n 1) }
|
||||
fn -- [n]{ to-string (- $n 1) }
|
||||
|
||||
notify-bg-job-success = $false
|
||||
|
||||
use moi/aliases
|
||||
edit:insert:binding[Tab] = { edit:completion:smart-start; edit:navigation:trigger-filter }
|
||||
edit:insert:binding[Ctrl-H] = $edit:histlist:start~
|
||||
|
||||
use github.com/zzamboni/elvish-completions/builtins
|
||||
use github.com/zzamboni/elvish-completions/git
|
||||
git:git-command = hub
|
||||
git:init
|
||||
use github.com/zzamboni/elvish-completions/cd
|
||||
use github.com/zzamboni/elvish-completions/ssh
|
||||
|
||||
use github.com/xiaq/edit.elv/compl/go
|
||||
edit:prompt = { go-prompt }
|
||||
edit:rprompt = { nop }
|
||||
|
||||
use moi/completion
|
||||
-source ~/.elvish/lib/moi/util.elv
|
||||
use moi/alias
|
||||
use moi/util/common
|
||||
|
||||
edit:insert:binding[Tab] = { edit:completion:smart-start } #; edit:navigation:trigger-filter }
|
||||
|
||||
set-env GOPATH ~/Go
|
||||
set-env PAGER 'bat -p'
|
||||
set-env EDITOR vim
|
||||
set-env VIEW 'vim -R'
|
||||
paths = [$@paths ~/bin $E:GOPATH/bin ]
|
||||
|
||||
-exports- = (aliases:export)
|
||||
|
||||
fn dcd [@_args]{
|
||||
use str
|
||||
cmd = (aliases:export); $cmd[br~] --only-folders --cmd (str:join ' ' $_args)' :cd'
|
||||
{
|
||||
use ./aliases/get-uid uid
|
||||
if (not (uid:-is-root)) {
|
||||
tache search -d 2w not del
|
||||
}
|
||||
}
|
||||
|
||||
tache search -d 2w not del
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user