Préparation à elvish 0.17
This commit is contained in:
parent
4170890f54
commit
08d0e16cff
@ -11,13 +11,13 @@ edit:add-var addbadips~ [@argv]{
|
||||
var cond = (and (not (has-key $m $e)) (ip:is-ipv4 $e))
|
||||
if $cond {
|
||||
echo $e ajoutée
|
||||
c = (+ $c 1)
|
||||
m[$e] = $nil
|
||||
ips = [ (all $ips) $e ]
|
||||
set c = (+ $c 1)
|
||||
set m[$e] = $nil
|
||||
set ips = [ (all $ips) $e ]
|
||||
}
|
||||
} $argv
|
||||
if (> $c 0) {
|
||||
ips = [ (list:sort $ip:cmp4~ $ips) ]
|
||||
set ips = [ (list:sort $ip:cmp4~ $ips) ]
|
||||
}
|
||||
var result = (str:join "\n" $ips)
|
||||
echo $result > $f
|
||||
|
@ -4,7 +4,7 @@ edit:add-var adguard~ [@argv]{
|
||||
var beg = 's|^.*\(192\.168\.0\.25\)|'
|
||||
var end = 'nameserver \1|'
|
||||
if (and (> (count $argv) 0) (str:has-prefix $argv[0] u)) {
|
||||
end = '# '$end
|
||||
set end = '# '$end
|
||||
}
|
||||
sudo sed -i $beg$end /etc/resolv.conf
|
||||
sudo chattr +i /etc/resolv.conf
|
||||
|
@ -4,7 +4,7 @@ edit:add-var curl~ $e:curlie~
|
||||
edit:add-var df~ $e:duf~
|
||||
edit:add-var diff~ $e:colordiff~
|
||||
edit:add-var dig~ [@argv]{ e:dig +noall +answer $@argv }
|
||||
edit:add-var dogall~ [@argv]{ e:dog A AAAA CNAME PTR TXT MX SRV NS SOA $@argv }
|
||||
edit:add-var dogall~ [@argv]{ e:dog A AAAA CNAME TXT MX NS SOA $@argv }
|
||||
edit:add-var du~ [@argv]{ e:du -h $@argv }
|
||||
edit:add-var git~ $e:hub~
|
||||
edit:add-var grep~ [@argv]{ e:grep --color=tty -d skip $@argv }
|
||||
|
@ -1,8 +1,8 @@
|
||||
cmd = $e:arc~
|
||||
var cmd = $e:arc~
|
||||
|
||||
edit:add-var archiver~ [@argv]{
|
||||
use str
|
||||
help = {
|
||||
var help = {
|
||||
echo "Usage : archiver [(-zlxgb)] <file to compress>"
|
||||
return
|
||||
}
|
||||
@ -11,7 +11,7 @@ edit:add-var archiver~ [@argv]{
|
||||
}
|
||||
var format o = zst $argv[0]
|
||||
if (and (str:has-prefix $o -) (> (count $o) 1)) {
|
||||
o = $o[1]
|
||||
set o = $o[1]
|
||||
var m = [
|
||||
&z=zst
|
||||
&l=lz4
|
||||
@ -22,7 +22,7 @@ edit:add-var archiver~ [@argv]{
|
||||
if (not (has-key $m $o)) {
|
||||
$help
|
||||
}
|
||||
format argv = $m[$o] $argv[1..]
|
||||
set format argv = $m[$o] $argv[1..]
|
||||
}
|
||||
if (== (count $argv) 0) {
|
||||
$help
|
||||
@ -30,7 +30,7 @@ edit:add-var archiver~ [@argv]{
|
||||
peach [f]{
|
||||
var ff = $f
|
||||
if (eq $ff[-1] /) {
|
||||
f = $ff[..-1]
|
||||
set f = $ff[..-1]
|
||||
}
|
||||
$cmd archive $ff'.tar.'$format $ff
|
||||
echo "'"$ff"'" archivé
|
||||
|
@ -20,10 +20,10 @@ edit:add-var cleankh~ [@argv]{
|
||||
cat ~/.ssh/known_hosts | eawk [_ hosts @rest]{
|
||||
var key = (str:join ' ' $rest)
|
||||
if (not (has-key $khosts $key)) {
|
||||
khosts[$key] = [&]
|
||||
set khosts[$key] = [&]
|
||||
}
|
||||
str:split , $hosts | each [h]{
|
||||
khosts[$key][$h] = $nil
|
||||
set khosts[$key][$h] = $nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,13 @@ edit:add-var commitkcp~ [@argv]{
|
||||
]
|
||||
|
||||
keys $m | each [k]{
|
||||
var p = 'pkg'$k'='
|
||||
m[$k] = (str:trim-prefix (cat PKGBUILD | grep $p | take 1) $p)
|
||||
var p = 'pkg'$k'='
|
||||
set m[$k] = (str:trim-prefix (cat PKGBUILD | grep $p | take 1) $p)
|
||||
}
|
||||
|
||||
var msg = $m[name]' '$m[ver]
|
||||
if (> (count $argv) 0) {
|
||||
msg = $msg' - '(str:join ' ' $argv)
|
||||
set msg = $msg' - '(str:join ' ' $argv)
|
||||
}
|
||||
|
||||
echo "git commit -am '"$msg"' ; git push"
|
||||
|
@ -21,7 +21,7 @@ edit:add-var digall~ [@argv]{
|
||||
[&min=10]
|
||||
]
|
||||
var records servers = [] []
|
||||
var flags = [
|
||||
var flags = [
|
||||
+noall
|
||||
+answer
|
||||
]
|
||||
@ -29,22 +29,22 @@ edit:add-var digall~ [@argv]{
|
||||
|
||||
fn init []{
|
||||
if (and (> (count $argv) 0) (is $argv[0] -d)) {
|
||||
use_dig = $false
|
||||
argv = $argv[1:]
|
||||
set use_dig = $false
|
||||
set argv = $argv[1:]
|
||||
}
|
||||
each [e]{
|
||||
if (is $e[0] '+') {
|
||||
flags = [ (all $flags) $e ]
|
||||
set flags = [ (all $flags) $e ]
|
||||
} elif (is $e[0] @) {
|
||||
servers = [ (all $servers) $e ]
|
||||
set servers = [ (all $servers) $e ]
|
||||
} elif (list:includes $e $default_records) {
|
||||
records = [ (all $records) $e ]
|
||||
set records = [ (all $records) $e ]
|
||||
} else {
|
||||
domains = [ (all $domains) $e ]
|
||||
set domains = [ (all $domains) $e ]
|
||||
}
|
||||
} $argv
|
||||
if (== (count $records) 0) {
|
||||
records = $default_records
|
||||
set records = $default_records
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ edit:add-var digall~ [@argv]{
|
||||
} $results | list:remove-duplicate | list:sort [l1 l2]{
|
||||
var c = (str:compare $l1[0] $l2[0])
|
||||
if (== $c 0) {
|
||||
c = (str:compare $l1[2] $l2[2])
|
||||
set c = (str:compare $l1[2] $l2[2])
|
||||
}
|
||||
} | strutil:format &col=$cols | str:join "\n"
|
||||
}
|
||||
@ -92,10 +92,10 @@ edit:add-var digall~ [@argv]{
|
||||
var results = [ (echo (styled 'Domaine: '$d bright-green)) ]
|
||||
if (> (count $servers) 0) {
|
||||
each [s]{
|
||||
@results = $@results (digs $s $d)
|
||||
set @results = $@results (digs $s $d)
|
||||
} $servers
|
||||
} else {
|
||||
@results = $@results (req $d)
|
||||
set @results = $@results (req $d)
|
||||
}
|
||||
echo (str:join "\n" $results)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ fn -get-id []{
|
||||
str:split ' ' (id) | each [e]{
|
||||
var p = [ (str:split '=' $e) ]
|
||||
if (== (count $p) 2) {
|
||||
id[$p[0]] = (-values $p[1])
|
||||
set id[$p[0]] = (-values $p[1])
|
||||
}
|
||||
}
|
||||
put $id
|
||||
|
@ -33,15 +33,15 @@ edit:add-var ipof~ [@argv]{
|
||||
str:split ', ' $value | peach [e]{
|
||||
var ee = $e
|
||||
if (ip:is-ip $ee) {
|
||||
result[ips][$ee] = $nil
|
||||
set result[ips][$ee] = $nil
|
||||
}
|
||||
}
|
||||
} elif (str:has-prefix $ll 'TXT records') {
|
||||
result[txt] = $value
|
||||
set result[txt] = $value
|
||||
} elif (str:has-prefix $ll 'Resolver') {
|
||||
result[resolvers] = $value
|
||||
set result[resolvers] = $value
|
||||
} elif (str:has-prefix $ll 'Name servers') {
|
||||
result[remote] = (not-eq $value 'name does not exist')
|
||||
set result[remote] = (not-eq $value 'name does not exist')
|
||||
}
|
||||
}
|
||||
put $result
|
||||
@ -57,9 +57,9 @@ edit:add-var ipof~ [@argv]{
|
||||
peach [d]{
|
||||
var dd = $d
|
||||
if (has-key $hosts $dd) {
|
||||
hosts[$dd][$ip] = $nil
|
||||
set hosts[$dd][$ip] = $nil
|
||||
} else {
|
||||
hosts[$dd] = [&$ip=$nil]
|
||||
set hosts[$dd] = [&$ip=$nil]
|
||||
}
|
||||
} $domains
|
||||
}
|
||||
@ -69,7 +69,7 @@ edit:add-var ipof~ [@argv]{
|
||||
var dd = $d
|
||||
var solve = (dnssolve $dd)
|
||||
if (> (keys $solve[ips] | count) 0) {
|
||||
remote[$dd] = $solve
|
||||
set remote[$dd] = $solve
|
||||
}
|
||||
} $argv
|
||||
|
||||
@ -78,14 +78,14 @@ edit:add-var ipof~ [@argv]{
|
||||
echo (styled 'Resolving '$d'…' bright-green)
|
||||
echo
|
||||
if (has-key $hosts $d) {
|
||||
exists = $true
|
||||
set exists = $true
|
||||
echo (styled ' local:' bright-yellow)
|
||||
keys $hosts[$d] | order &less-than=$sort-ip~ | each [ip]{
|
||||
echo ' - '$ip
|
||||
}
|
||||
}
|
||||
if (and (has-key $remote $d) $remote[$d][remote]) {
|
||||
exists = $true
|
||||
set exists = $true
|
||||
var info = $remote[$d]
|
||||
echo (styled ' remote:' bright-yellow)
|
||||
echo ' IPs:'
|
||||
|
@ -32,15 +32,15 @@ edit:add-var pdf2grey~ [@argv]{
|
||||
_help
|
||||
return
|
||||
} elif (eq $e -n) {
|
||||
m[nb] = $true
|
||||
set m[nb] = $true
|
||||
if (== (count $e) 0) {
|
||||
echo 'Il manque des arguments après -s'
|
||||
_help
|
||||
return
|
||||
} elif (is_int $argv[0]) {
|
||||
e @argv = $@argv
|
||||
set e @argv = $@argv
|
||||
if (is_split $e) {
|
||||
m[split] = $e
|
||||
set m[split] = $e
|
||||
} else {
|
||||
echo 'L’argument (optionnel) après -s doit être compris entre 0 et 100'
|
||||
_help
|
||||
@ -52,9 +52,9 @@ edit:add-var pdf2grey~ [@argv]{
|
||||
_help
|
||||
return
|
||||
} elif (not (has-key $m input)) {
|
||||
m[input] = $e
|
||||
set m[input] = $e
|
||||
} else {
|
||||
m[output] = $e
|
||||
set m[output] = $e
|
||||
if (> (count $argv) 0) {
|
||||
echo 'Trop d’arguments: '$@argv
|
||||
_help
|
||||
@ -74,9 +74,9 @@ edit:add-var pdf2grey~ [@argv]{
|
||||
|
||||
var params = [-colorspace gray]
|
||||
if $m[nb] {
|
||||
@params = (all $params) -threshold $m[split]'%'
|
||||
set @params = (all $params) -threshold $m[split]'%'
|
||||
}
|
||||
@params = $@params $m[input] $m[output]
|
||||
set @params = $@params $m[input] $m[output]
|
||||
echo 'Commande: convert '(str:join ' ' $params)
|
||||
convert $@params
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
edit:add-var publicip~ [@argv]{
|
||||
f = [t]{
|
||||
var f = [t]{
|
||||
use moi/util/condition
|
||||
t = (condition:cset (eq $t -6) -6 -4)
|
||||
l = (condition:cset (eq $t -6) 'IPv6: ' 'IPv4: ')
|
||||
set t = (condition:cset (eq $t -6) -6 -4)
|
||||
var 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
|
||||
|
Loading…
Reference in New Issue
Block a user