Tous les modules utilisés sont désormais déportés sur framagit; modification des alias en conséquence (sauf ceux concernant les pdf)
This commit is contained in:
parent
8c138abe1a
commit
3c990f7cff
|
@ -1,3 +1,4 @@
|
||||||
*.old
|
*.old
|
||||||
lib/github.com
|
lib/github.com
|
||||||
|
lib/framagit.org
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,25 +1,34 @@
|
||||||
edit:add-var addbadips~ {|@argv|
|
edit:add-var addbadips~ {|@argv|
|
||||||
use moi/util/ip
|
|
||||||
use moi/util/list
|
|
||||||
use moi/util/map
|
|
||||||
use str
|
use str
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/map
|
||||||
|
|
||||||
var f = ~/bad_ips.txt
|
fn add {|f cmp ips|
|
||||||
var ips = [ (cat $f) ]
|
var @cips = (cat $f)
|
||||||
var m c = (map:to-set $ips) 0
|
var m c = (map:to-set $cips) 0
|
||||||
each {|e|
|
each {|e|
|
||||||
var cond = (and (not (has-key $m $e)) (ip:is-ipv4 $e))
|
if (not (has-key $m $e)) {
|
||||||
if $cond {
|
echo $e ajoutée
|
||||||
echo $e ajoutée
|
set c = (+ $c 1)
|
||||||
set c = (+ $c 1)
|
set m[$e] = $nil
|
||||||
set m[$e] = $nil
|
set @cips = $@cips $e
|
||||||
set ips = [ (all $ips) $e ]
|
}
|
||||||
|
} $ips
|
||||||
|
if (> $c 0) {
|
||||||
|
set @cips = (list:sort $cmp $cips)
|
||||||
|
echo (str:join "\n" $cips) > $f
|
||||||
}
|
}
|
||||||
} $argv
|
put $c (count $cips)
|
||||||
if (> $c 0) {
|
}
|
||||||
set ips = [ (list:sort $ip:cmp4~ $ips) ]
|
|
||||||
|
var ip4 ip6 = (list:filter $ip:is-ip~ $argv | list:unzip {|_ ip| ip:is-ipv4 $ip})
|
||||||
|
if (list:is-not-empty $ip4) {
|
||||||
|
var c t = (add $E:HOME/bad_ips.txt $ip:comp4~ $ip4)
|
||||||
|
printf "%d IPv4s ajoutées (%d au total)\n" $c $t
|
||||||
|
}
|
||||||
|
if (list:is-not-empty $ip6) {
|
||||||
|
var c t = (add $E:HOME/bad_ipsv6.txt $ip:comp6~ $ip6)
|
||||||
|
printf "%d IPv6s ajoutées (%d au total)\n" $c $t
|
||||||
}
|
}
|
||||||
var result = (str:join "\n" $ips)
|
|
||||||
echo $result > $f
|
|
||||||
echo $c' IPs ajoutées ('(count $ips)' au total)'
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,9 @@ edit:add-var archiver~ {|@argv|
|
||||||
$help
|
$help
|
||||||
}
|
}
|
||||||
peach {|f|
|
peach {|f|
|
||||||
var ff = $f
|
var ff = (str:trim-suffix $f '/')
|
||||||
if (eq $ff[-1] /) {
|
|
||||||
set f = $ff[..-1]
|
|
||||||
}
|
|
||||||
$cmd archive $ff'.tar.'$format $ff
|
$cmd archive $ff'.tar.'$format $ff
|
||||||
echo "'"$ff"'" archivé
|
printf "'%s' archivé\n" $ff
|
||||||
} $argv
|
} $argv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +38,7 @@ edit:add-var desarchiver~ {|@argv|
|
||||||
peach {|f|
|
peach {|f|
|
||||||
var ff = $f
|
var ff = $f
|
||||||
$cmd unarchive $ff
|
$cmd unarchive $ff
|
||||||
echo "'"$ff"'" désarchivé
|
printf "'%s' désarchivé\n" $ff
|
||||||
} $argv
|
} $argv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
edit:add-var updatecarapace~ {||
|
edit:add-var updatecarapace~ {||
|
||||||
|
use path
|
||||||
var cur = (pwd)
|
var cur = (pwd)
|
||||||
var wd = $E:HOME/Documents/OtherGo/github.com/rsteube/carapace-bin
|
var wd = $E:HOME/Documents/OtherGo/github.com/rsteube/carapace-bin
|
||||||
var bd = $E:HOME/Go/bin
|
var bd = $E:HOME/Go/bin
|
||||||
|
@ -7,7 +8,7 @@ edit:add-var updatecarapace~ {||
|
||||||
cd cmd/carapace
|
cd cmd/carapace
|
||||||
go generate ./...
|
go generate ./...
|
||||||
go build -ldflags="-s -w" -tags release
|
go build -ldflags="-s -w" -tags release
|
||||||
if (bool ?(test -f carapace)) {
|
if (path:is-regular carapace) {
|
||||||
mv -f carapace $bd
|
mv -f carapace $bd
|
||||||
}
|
}
|
||||||
cd $cur
|
cd $cur
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use str
|
use str
|
||||||
|
|
||||||
fn -check {|f|
|
fn -check {|f|
|
||||||
|
use str
|
||||||
var @missings = (try {
|
var @missings = (try {
|
||||||
sudo ldd $f 2>/dev/null | grep 'not found' | eawk {|_ m @_| put $m }
|
sudo ldd $f 2>/dev/null | grep 'not found' | eawk {|_ m @_| put $m }
|
||||||
} except e {
|
} except e {
|
||||||
})
|
})
|
||||||
if (> (count $missings) 1) {
|
if (> (count $missings) 1) {
|
||||||
var p = (LC_ALL=C pacman -Qo $f)
|
var p = (LC_ALL=C pacman -Qo $f)
|
||||||
echo $p' seem broken: missing '(str:join ', ' $missings)
|
printf "%s seem broken: missing %s\n" $p (str:join ', ' $missings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
edit:add-var cleankh~ {|@argv|
|
edit:add-var cleankh~ {|@argv|
|
||||||
use str
|
use str
|
||||||
use moi/util/condition
|
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
||||||
use moi/util/list
|
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
|
||||||
use moi/util/ip
|
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
||||||
fn less {|cmp e1 e2| < ($cmp $e1 $e2) 0 }
|
|
||||||
fn sort-host {|e1 e2|
|
fn sort-host {|e1 e2|
|
||||||
var i1 = (condition:cset (ip:is-ip $e1) 1 0)
|
var i1 = (common:cond (ip:is-ip $e1) 1 0)
|
||||||
var i2 = (condition:cset (ip:is-ip $e2) 1 0)
|
var i2 = (common:cond (ip:is-ip $e2) 1 0)
|
||||||
if (!= $i1 $i2) {
|
if (!= $i1 $i2) {
|
||||||
< $i1 $i2
|
- $i1 $i2
|
||||||
} elif (== $i1 0) {
|
} elif (== $i1 0) {
|
||||||
<s $e1 $e2
|
compare $e1 $e2
|
||||||
} else {
|
} else {
|
||||||
less $ip:cmp~ $e1 $e2
|
ip:comp $e1 $e2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,8 @@ edit:add-var cleankh~ {|@argv|
|
||||||
}
|
}
|
||||||
|
|
||||||
var lines = [(keys $khosts | each {|key|
|
var lines = [(keys $khosts | each {|key|
|
||||||
var hosts = (keys $khosts[$key] | order &less-than=$sort-host~ | str:join ,)
|
var hosts = (keys $khosts[$key] | list:sort $sort-host~ | str:join ,)
|
||||||
put $hosts $key | str:join ' '
|
put $hosts $key | str:join ' '
|
||||||
})]
|
})]
|
||||||
echo (str:join "\n" $lines) > ~/.ssh/known_hosts
|
echo (str:join "\n" $lines) > ~/.ssh/known_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
edit:add-var commitkcp~ {|@argv|
|
edit:add-var commitkcp~ {|@argv|
|
||||||
use str
|
use str
|
||||||
|
|
||||||
var m = [
|
var m = [
|
||||||
&name=
|
&name=
|
||||||
&ver=
|
&ver=
|
||||||
]
|
]
|
||||||
|
|
||||||
keys $m | each {|k|
|
keys $m | each {|k|
|
||||||
var p = 'pkg'$k'='
|
var p = (printf 'pkg%s=' $k)
|
||||||
set m[$k] = (str:trim-prefix (cat PKGBUILD | grep $p | take 1) $p)
|
set m[$k] = (str:trim-prefix (cat PKGBUILD | grep $p | take 1) $p)
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = $m[name]' '$m[ver]
|
var msg = (printf '%s %s' $m[name] $m[ver])
|
||||||
if (> (count $argv) 0) {
|
if (> (count $argv) 0) {
|
||||||
set msg = $msg' - '(str:join ' ' $argv)
|
set msg = (printf '%s - %s' $msg (str:join ' ' $argv))
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "git commit -am '"$msg"' ; git push"
|
printf "git commit -am '%s'; git push" $msg
|
||||||
git commit -am $msg; git push
|
git commit -am $msg; git push
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
edit:add-var digall~ {|@argv|
|
edit:add-var digall~ {|@argv|
|
||||||
use moi/util/list
|
|
||||||
use moi/util/strutil
|
|
||||||
use str
|
use str
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/format
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
||||||
|
|
||||||
var default_records = [
|
var default_records = [
|
||||||
A
|
A
|
||||||
|
@ -15,11 +16,6 @@ edit:add-var digall~ {|@argv|
|
||||||
NS
|
NS
|
||||||
SOA
|
SOA
|
||||||
]
|
]
|
||||||
var cols = [
|
|
||||||
[&min=24]
|
|
||||||
[&min=8]
|
|
||||||
[&min=10]
|
|
||||||
]
|
|
||||||
var records servers = [] []
|
var records servers = [] []
|
||||||
var flags = [
|
var flags = [
|
||||||
+noall
|
+noall
|
||||||
|
@ -27,23 +23,22 @@ edit:add-var digall~ {|@argv|
|
||||||
]
|
]
|
||||||
var domains use_dig = [] $true
|
var domains use_dig = [] $true
|
||||||
|
|
||||||
fn init {||
|
fn init {
|
||||||
if (and (> (count $argv) 0) (is $argv[0] -d)) {
|
if (and (list:is-not-empty $argv) (eq $argv[0] -d)) {
|
||||||
set use_dig = $false
|
set use_dig argv = $false $argv[1..]
|
||||||
set argv = $argv[1:]
|
|
||||||
}
|
}
|
||||||
each {|e|
|
each {|e|
|
||||||
if (is $e[0] '+') {
|
if (eq $e[0] +) {
|
||||||
set flags = [ (all $flags) $e ]
|
set @flags = $@flags $e
|
||||||
} elif (is $e[0] @) {
|
} elif (eq $e[0] @) {
|
||||||
set servers = [ (all $servers) $e ]
|
set @servers = $@servers $e
|
||||||
} elif (list:includes $e $default_records) {
|
} elif (list:contains $e $default_records) {
|
||||||
set records = [ (all $records) $e ]
|
set @records = $@records $e
|
||||||
} else {
|
} else {
|
||||||
set domains = [ (all $domains) $e ]
|
set @domains = $@domains $e
|
||||||
}
|
}
|
||||||
} $argv
|
} $argv
|
||||||
if (== (count $records) 0) {
|
if (list:is-empty $records) {
|
||||||
set records = $default_records
|
set records = $default_records
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,35 +47,32 @@ edit:add-var digall~ {|@argv|
|
||||||
eawk {|_ @args|
|
eawk {|_ @args|
|
||||||
put [ $args[0] (all $args[2..]) ]
|
put [ $args[0] (all $args[2..]) ]
|
||||||
} $results | list:remove-duplicate | list:sort {|l1 l2|
|
} $results | list:remove-duplicate | list:sort {|l1 l2|
|
||||||
var c = (str:compare $l1[0] $l2[0])
|
var c = (compare $l1[0] $l2[0])
|
||||||
if (== $c 0) {
|
if (== $c 0) {
|
||||||
set c = (str:compare $l1[2] $l2[2])
|
set c = (compare $l1[2] $l2[2])
|
||||||
}
|
}
|
||||||
} | strutil:format &col=$cols | str:join "\n"
|
put $c
|
||||||
|
} | each {|e| str:join ' ' $e} | format:tabulate
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drillr {|d @args|
|
fn drillr {|d @args|
|
||||||
var results = [ (peach {|r|
|
var @results = (peach {|r|
|
||||||
e:drill $@args $r $d | list:filter {|e|
|
e:drill $@args $r $d | list:filter {|e|
|
||||||
and (> (count $e) 2) (not (is $e[:2] ';;'))
|
and (> (count $e) 2) (not-eq $e[..2] ';;')
|
||||||
}
|
}
|
||||||
} $records) ]
|
} $records)
|
||||||
format $results
|
format $results
|
||||||
}
|
}
|
||||||
|
|
||||||
fn digr {|d @args|
|
fn digr {|d @args|
|
||||||
var results = [ (peach {|r|
|
var @results = (peach {|r|
|
||||||
e:dig $@args $r $d $@flags
|
e:dig $@args $r $d $@flags
|
||||||
} $records) ]
|
} $records)
|
||||||
format $results
|
format $results
|
||||||
}
|
}
|
||||||
|
|
||||||
fn req {|d @args|
|
fn req {|d @args|
|
||||||
if $use_dig {
|
common:cexec $use_dig { digr $d $@args } { drillr $d $@args }
|
||||||
digr $d $@args
|
|
||||||
} else {
|
|
||||||
drillr $d $@args
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn digs {|s d|
|
fn digs {|s d|
|
||||||
|
@ -89,8 +81,8 @@ edit:add-var digall~ {|@argv|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn digd {|d|
|
fn digd {|d|
|
||||||
var results = [ (echo (styled 'Domaine: '$d bright-green)) ]
|
var @results = (echo (styled 'Domaine: '$d bright-green))
|
||||||
if (> (count $servers) 0) {
|
if (list:is-not-empty $servers) {
|
||||||
each {|s|
|
each {|s|
|
||||||
set @results = $@results (digs $s $d)
|
set @results = $@results (digs $s $d)
|
||||||
} $servers
|
} $servers
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use re
|
|
||||||
use str
|
|
||||||
|
|
||||||
fn -value {|v|
|
fn -value {|v|
|
||||||
|
use re
|
||||||
var p = (re:find '^(\d+)\((\w+)\)$' $v)
|
var p = (re:find '^(\d+)\((\w+)\)$' $v)
|
||||||
if (and (has-key $p groups) (== (count $p[groups]) 3)) {
|
if (and (has-key $p groups) (== (count $p[groups]) 3)) {
|
||||||
put [
|
put [
|
||||||
|
@ -12,7 +10,8 @@ fn -value {|v|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn -values {|v|
|
fn -values {|v|
|
||||||
var vv = [ (str:split ',' $v) ]
|
use str
|
||||||
|
var @vv = (str:split ',' $v)
|
||||||
if (== (count $vv) 1) {
|
if (== (count $vv) 1) {
|
||||||
-value $vv[0]
|
-value $vv[0]
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,10 +19,11 @@ fn -values {|v|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn -get-id {||
|
fn -get-id {
|
||||||
|
use str
|
||||||
var id = [&]
|
var id = [&]
|
||||||
str:split ' ' (id) | each {|e|
|
str:split ' ' (id) | each {|e|
|
||||||
var p = [ (str:split '=' $e) ]
|
var @p = (str:split '=' $e)
|
||||||
if (== (count $p) 2) {
|
if (== (count $p) 2) {
|
||||||
set id[$p[0]] = (-values $p[1])
|
set id[$p[0]] = (-values $p[1])
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
edit:add-var ipinfo~ {|@argv|
|
edit:add-var ipinfo~ {|@argv|
|
||||||
use moi/util/ip
|
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
|
||||||
use str
|
|
||||||
|
|
||||||
var token = (cat $E:HOME/.config/elvish/private/ipinfo_token)
|
var token = (cat $E:HOME/.config/elvish/private/ipinfo_token)
|
||||||
|
|
||||||
fn url-of {|ip|
|
fn url-of {|ip|
|
||||||
str:join '' [ 'ipinfo.io/' $ip '?token=' $token]
|
printf 'ipinfo.io/%s?token=%s' $ip $token
|
||||||
}
|
}
|
||||||
|
|
||||||
fn info {|ip|
|
fn info {|ip|
|
||||||
if (ip:is-ip $ip) {
|
if (ip:is-ip $ip) {
|
||||||
var url = (url-of $ip)
|
var url = (url-of $ip)
|
||||||
echo 'URL: '$url
|
printf "URL: %s\n" $url
|
||||||
e:curlie $url
|
e:curlie $url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
edit:add-var ipof~ {|@argv|
|
edit:add-var ipof~ {|@argv|
|
||||||
use str
|
use str
|
||||||
use moi/util/condition
|
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
||||||
use moi/util/ip
|
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
||||||
fn less {|cmp e1 e2| < ($cmp $e1 $e2) 0 }
|
use framagit.org/benjamin.vaudour/elv-lib/mods/num
|
||||||
|
|
||||||
fn sort-ip {|e1 e2|
|
fn sort-ip {|e1 e2|
|
||||||
var i1 = (condition:cset (ip:is-ipv4 $e1) 0 (condition:cset (ip:is-ipv6 $e1) 1 2))
|
var check = {|e| common:cexec (ip:is-ipv4 $e) 0 { common:cond (ip:is-ipv6 $e) 1 2 }}
|
||||||
var i2 = (condition:cset (ip:is-ipv4 $e2) 0 (condition:cset (ip:is-ipv6 $e2) 1 2))
|
var i1 = ($check $e1)
|
||||||
if (!= $i1 $i2) {
|
var i2 = ($check $e2)
|
||||||
< $i1 $i2
|
if (or (!= $i1 $i2) (== $i1 2)) {
|
||||||
} elif (== $i1 2) {
|
compare $i1 $i2
|
||||||
<s $e1 $e2
|
|
||||||
} elif (== $i1 1) {
|
} elif (== $i1 1) {
|
||||||
less $ip:cmp6~ $e1 $e2
|
ip:comp6 $e1 $e2
|
||||||
} else {
|
} else {
|
||||||
less $ip:cmp4~ $e1 $e2
|
ip:comp4 $e1 $e2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +26,8 @@ edit:add-var ipof~ {|@argv|
|
||||||
]
|
]
|
||||||
e:dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml -resolve (idn -a $d) | peach {|l|
|
e:dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml -resolve (idn -a $d) | peach {|l|
|
||||||
var ll = $l
|
var ll = $l
|
||||||
var idx = (+ (str:index $ll :) 1)
|
var idx = (num:++ (str:index $ll :))
|
||||||
var value = (str:trim-space $ll[$idx".."])
|
var value = (str:trim-space $ll[$idx..])
|
||||||
if (or (str:has-prefix $ll 'IPv4 addresses') (str:has-prefix $ll 'IPv6 addresses')) {
|
if (or (str:has-prefix $ll 'IPv4 addresses') (str:has-prefix $ll 'IPv6 addresses')) {
|
||||||
str:split ', ' $value | peach {|e|
|
str:split ', ' $value | peach {|e|
|
||||||
var ee = $e
|
var ee = $e
|
||||||
|
@ -68,20 +67,19 @@ edit:add-var ipof~ {|@argv|
|
||||||
peach {|d|
|
peach {|d|
|
||||||
var dd = $d
|
var dd = $d
|
||||||
var solve = (dnssolve $dd)
|
var solve = (dnssolve $dd)
|
||||||
if (> (keys $solve[ips] | count) 0) {
|
if (> (count $solve[ips]) 0) {
|
||||||
set remote[$dd] = $solve
|
set remote[$dd] = $solve
|
||||||
}
|
}
|
||||||
} $argv
|
} $argv
|
||||||
|
|
||||||
each {|d|
|
each {|d|
|
||||||
var exists = $false
|
var exists = $false
|
||||||
echo (styled 'Resolving '$d'…' bright-green)
|
echo (styled (printf "Resolving '%s'…\n" $d) bright-green)
|
||||||
echo
|
|
||||||
if (has-key $hosts $d) {
|
if (has-key $hosts $d) {
|
||||||
set exists = $true
|
set exists = $true
|
||||||
echo (styled ' local:' bright-yellow)
|
echo (styled ' local:' bright-yellow)
|
||||||
keys $hosts[$d] | order &less-than=$sort-ip~ | each {|ip|
|
keys $hosts[$d] | list:sort $sort-ip~ | each {|ip|
|
||||||
echo ' - '$ip
|
printf " - %s\n" $ip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (and (has-key $remote $d) $remote[$d][remote]) {
|
if (and (has-key $remote $d) $remote[$d][remote]) {
|
||||||
|
@ -89,11 +87,11 @@ edit:add-var ipof~ {|@argv|
|
||||||
var info = $remote[$d]
|
var info = $remote[$d]
|
||||||
echo (styled ' remote:' bright-yellow)
|
echo (styled ' remote:' bright-yellow)
|
||||||
echo ' IPs:'
|
echo ' IPs:'
|
||||||
keys $info[ips] | order &less-than=$sort-ip~ | each {|ip|
|
keys $info[ips] | list:sort $sort-ip~ | each {|ip|
|
||||||
echo ' - '$ip
|
printf " - %s\n" $ip
|
||||||
}
|
}
|
||||||
echo ' Resolvers: '$info[resolvers]
|
printf " Resolvers: %s\n" $info[resolvers]
|
||||||
echo ' TXT records: '$info[txt]
|
printf " TXT records: %s\n" $info[txt]
|
||||||
}
|
}
|
||||||
if (not $exists) {
|
if (not $exists) {
|
||||||
echo (styled 'No info found' bright-red)
|
echo (styled 'No info found' bright-red)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
edit:add-var meteo~ {|@argv|
|
edit:add-var meteo~ {|@argv|
|
||||||
use str
|
use str
|
||||||
#curl --connect-timeout 2 "wttr.in/"(joins '' $_args)"?lang=fr"
|
var url = (printf 'wttr.in/%s?lang=fr' (str:join '' $argv))
|
||||||
e:curlie -s --connect-timeout 2 "wttr.in/"(str:join '' $argv)"?lang=fr"
|
#curl --connect-timeout 2 $url
|
||||||
|
e:curlie -s --connect-timeout 2 $url
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
edit:add-var publicip~ {|@argv|
|
edit:add-var publicip~ {|@argv|
|
||||||
|
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
||||||
var f = {|t|
|
var f = {|t|
|
||||||
use moi/util/condition
|
use moi/util/condition
|
||||||
set t = (condition:cset (eq $t -6) -6 -4)
|
set t = (common:cond (eq $t -6) -6 -4)
|
||||||
var l = (condition:cset (eq $t -6) 'IPv6: ' 'IPv4: ')
|
var l = (common:cond (eq $t -6) 'IPv6: ' 'IPv4: ')
|
||||||
curl $t ifconfig.co/ip 2> /dev/null | each {|ip| echo (styled $l bold yellow) $ip }
|
e:curl $t ifconfig.co/ip 2> /dev/null | each {|ip| echo (styled $l bold yellow) $ip}
|
||||||
}
|
}
|
||||||
$f -4
|
$f -4
|
||||||
$f -6
|
$f -6
|
||||||
|
|
|
@ -1,94 +1,67 @@
|
||||||
use str
|
edit:add-var genstr~ {|@argv|
|
||||||
use re
|
use re
|
||||||
|
use str
|
||||||
|
|
||||||
fn -bytes {|begin size|
|
fn j {|@strings| str:join '' $strings}
|
||||||
str:from-codepoints (range $begin (+ $begin $size))
|
fn bytes {|begin size| str:from-codepoints (range $begin (+ $begin $size))}
|
||||||
}
|
fn upper { bytes 0x41 26 }
|
||||||
|
fn lower { bytes 0x61 26 }
|
||||||
|
fn digit { bytes 0x30 10 }
|
||||||
|
fn alpha { j (upper) (lower) }
|
||||||
|
fn alphanum { j (alpha) (digit) }
|
||||||
|
|
||||||
fn -upper {||
|
fn random {|chars|
|
||||||
-bytes 0x41 26
|
var size = (count $chars)
|
||||||
}
|
print $chars[(randint 0 $size)]
|
||||||
|
}
|
||||||
|
fn is-int {|arg| re:match '^\d+$' $arg}
|
||||||
|
|
||||||
fn -lower {||
|
fn help {||
|
||||||
-bytes 0x61 26
|
echo 'Génère une chaîne de caractères aléatoires'
|
||||||
}
|
echo 'Usage: genstr [(-auldh)] [<chars>] [<size>]'
|
||||||
|
echo ''
|
||||||
|
echo 'Options:'
|
||||||
|
echo ' -a Uniquement des lettres ([A-Za-z])'
|
||||||
|
echo ' -u Uniquement des lettres majuscules ([A-Z])'
|
||||||
|
echo ' -l Uniquement des lettres minuscules ([a-z])'
|
||||||
|
echo ' -d Uniquement des chiffres ([0-9])'
|
||||||
|
echo ''
|
||||||
|
echo '<chars> Liste de caractères possibles'
|
||||||
|
echo '<size> Longueur de la chaîne (par défaut: 10)'
|
||||||
|
echo ''
|
||||||
|
echo 'Si aucune classe de caractères ou liste de caractères n’est fournie, utilise les caractères alphanumériques ([A-Za-z0-9]).'
|
||||||
|
}
|
||||||
|
|
||||||
fn -digit {||
|
|
||||||
-bytes 0x30 10
|
|
||||||
}
|
|
||||||
|
|
||||||
fn -j {|@strings|
|
|
||||||
str:join '' $strings
|
|
||||||
}
|
|
||||||
|
|
||||||
fn -alpha {||
|
|
||||||
-j (-upper) (-lower)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn -alphanum {||
|
|
||||||
-j (-alpha) (-digit)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn -random {|chars|
|
|
||||||
var size = (count $chars)
|
|
||||||
print $chars[(randint 0 $size)]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn -is-int {|arg|
|
|
||||||
re:match '^\d+$' $arg
|
|
||||||
}
|
|
||||||
|
|
||||||
fn -help {||
|
|
||||||
echo 'Génère une chaîne de caractères aléatoires'
|
|
||||||
echo 'Usage: genstr [(-auldh)] [<chars>] [<size>]'
|
|
||||||
echo ''
|
|
||||||
echo 'Options:'
|
|
||||||
echo ' -a Uniquement des lettres ([A-Za-z])'
|
|
||||||
echo ' -u Uniquement des lettres majuscules ([A-Z])'
|
|
||||||
echo ' -l Uniquement des lettres minuscules ([a-z])'
|
|
||||||
echo ' -d Uniquement des chiffres ([0-9])'
|
|
||||||
echo ''
|
|
||||||
echo '<chars> Liste de caractères possibles'
|
|
||||||
echo '<size> Longueur de la chaîne (par défaut: 10)'
|
|
||||||
echo ''
|
|
||||||
echo 'Si aucune classe de caractères ou liste de caractères n’est fournie, utilise les caractères alphanumériques ([A-Za-z0-9]).'
|
|
||||||
}
|
|
||||||
|
|
||||||
edit:add-var genstr~ {|@args|
|
|
||||||
var len chars h = 0 '' $false
|
var len chars h = 0 '' $false
|
||||||
each {|e|
|
each {|e|
|
||||||
if (or (eq $e -h) (eq $e --help)) {
|
if (or (eq $e -h) (eq $e --help)) {
|
||||||
set h = $true
|
set h = $true
|
||||||
-help
|
help
|
||||||
break
|
break
|
||||||
} elif (eq $e -a) {
|
} elif (eq $e -a) {
|
||||||
set chars = (-j $chars (-alpha))
|
set chars = (j $chars (alpha))
|
||||||
} elif (eq $e -u) {
|
} elif (eq $e -u) {
|
||||||
set chars = (-j $chars (-upper))
|
set chars = (j $chars (upper))
|
||||||
} elif (eq $e -l) {
|
} elif (eq $e -l) {
|
||||||
set chars = (-j $chars (-lower))
|
set chars = (j $chars (lower))
|
||||||
} elif (eq $e -d) {
|
} elif (eq $e -d) {
|
||||||
set chars = (-j $chars (-digit))
|
set chars = (j $chars (digit))
|
||||||
} elif (and (-is-int $e) (> $e 0)) {
|
} elif (and (is-int $e) (> $e 0)) {
|
||||||
set len = $e
|
set len = $e
|
||||||
} else {
|
} else {
|
||||||
set chars = (-j $chars $e)
|
set chars = (j $chars $e)
|
||||||
}
|
}
|
||||||
} $args
|
} $argv
|
||||||
|
|
||||||
if (not $h) {
|
if (not $h) {
|
||||||
if (== $len 0) {
|
if (== $len 0) {
|
||||||
set len = 10
|
set len = 10
|
||||||
}
|
}
|
||||||
if (eq $chars '') {
|
if (eq $chars '') {
|
||||||
set chars = (-alphanum)
|
set chars = (alphanum)
|
||||||
}
|
|
||||||
|
|
||||||
set chars = [(str:split '' $chars)]
|
|
||||||
|
|
||||||
range $len | each {|_|
|
|
||||||
-random $chars
|
|
||||||
}
|
}
|
||||||
|
set @chars = (str:split '' $chars)
|
||||||
|
range $len | each {|_| random $chars}
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
edit:add-var riot~ {||
|
edit:add-var riot~ {
|
||||||
cat $E:HOME/.config/elvish/private/riot.txt | xclip -selection clipboard
|
cat $E:HOME/.config/elvish/private/riot.txt | xclip -selection clipboard
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ edit:add-var sendsms~ {|@argv|
|
||||||
var param = (cat $E:HOME/.config/elvish/private/freesms.json | from-json)
|
var param = (cat $E:HOME/.config/elvish/private/freesms.json | from-json)
|
||||||
var msg = (str:join '%20' $argv)
|
var msg = (str:join '%20' $argv)
|
||||||
|
|
||||||
var url = $api'?user='$param[user]'&pass='$param[password]'&msg='$msg
|
var url = (printf '%s?user=%s&pass=%s&msg=%s' $api $param[user] $param[password] $msg)
|
||||||
#put $url
|
#put $url
|
||||||
curl $url
|
e:curl $url
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue