Ajout des fichiers manquants
This commit is contained in:
parent
ff9cefd28f
commit
62ebf74ebe
|
@ -0,0 +1,2 @@
|
|||
lib/github.com
|
||||
private
|
|
@ -0,0 +1,26 @@
|
|||
edit:add-var addbadips~ [@argv]{
|
||||
use moi/util/ip
|
||||
use moi/util/list
|
||||
use moi/util/map
|
||||
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 = (+ $c 1)
|
||||
m[$e] = $nil
|
||||
ips = [ (all $ips) $e ]
|
||||
}
|
||||
} $argv
|
||||
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)'
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
edit:add-var adguard~ [@argv]{
|
||||
use str
|
||||
sudo chattr -i /etc/resolv.conf
|
||||
local:beg = 's|^.*\(192\.168\.0\.25\)|'
|
||||
local:end = 'nameserver \1|'
|
||||
if (and (> (count $argv) 0) (str:has-prefix $argv[0] u)) {
|
||||
end = '# '$end
|
||||
}
|
||||
sudo sed -i $beg$end /etc/resolv.conf
|
||||
sudo chattr +i /etc/resolv.conf
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
edit:add-var cat~ [@argv]{ e:bat -pp --tabs 2 $@argv }
|
||||
edit:add-var cp~ [@argv]{ e:cp -iv $@argv }
|
||||
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 $@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 }
|
||||
edit:add-var mv~ [@argv]{ e:mv -iv $@argv }
|
||||
edit:add-var pf~ [@argv]{ e:pkgfile -vri $@argv }
|
||||
edit:add-var rm~ [@argv]{ e:rm -Iv $@argv }
|
||||
edit:add-var rename~ $e:go-rename~
|
||||
edit:add-var timidity~ [@argv]{ e:timidity -a -K 1 $@argv }
|
||||
edit:add-var tree~ [@argv]{ e:tree -puhC --dirsfirst --du -D $@argv }
|
|
@ -0,0 +1,36 @@
|
|||
edit:add-var cleankh~ [@argv]{
|
||||
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:cset (ip:is-ip $e1) 1 0)
|
||||
local:i2 = (condition:cset (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
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
edit:add-var commitkcp~ [@argv]{
|
||||
use str
|
||||
local:m = [
|
||||
&name=
|
||||
&ver=
|
||||
]
|
||||
|
||||
keys $m | each [k]{
|
||||
local:p = 'pkg'$k'='
|
||||
m[$k] = (str:trim-prefix (cat PKGBUILD | grep $p | take 1) $p)
|
||||
}
|
||||
|
||||
local:msg = $m[name]' '$m[ver]
|
||||
if (> (count $argv) 0) {
|
||||
msg = $msg' - '(str:join ' ' $argv)
|
||||
}
|
||||
|
||||
echo "git commit -am '"$msg"' ; git push"
|
||||
git commit -am $msg; git push
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
use re
|
||||
use str
|
||||
|
||||
fn -value [v]{
|
||||
local:p = (re:find '^(\d+)\((\w+)\)$' $v)
|
||||
if (and (has-key $p groups) (== (count $p[groups]) 3)) {
|
||||
put [
|
||||
&number=$p[groups][1][text]
|
||||
&text=$p[groups][2][text]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
fn -values [v]{
|
||||
local:vv = [ (str:split ',' $v) ]
|
||||
if (== (count $vv) 1) {
|
||||
-value $vv[0]
|
||||
} else {
|
||||
put [ (each $-value~ $vv) ]
|
||||
}
|
||||
}
|
||||
|
||||
fn -get-id []{
|
||||
local:id = [&]
|
||||
str:split ' ' (id) | each [e]{
|
||||
local:p = [ (str:split '=' $e) ]
|
||||
if (== (count $p) 2) {
|
||||
id[$p[0]] = (-values $p[1])
|
||||
}
|
||||
}
|
||||
put $id
|
||||
}
|
||||
|
||||
fn -get [k]{
|
||||
local:id = (-get-id)
|
||||
if (has-key $id $k) {
|
||||
put $id[$k]
|
||||
}
|
||||
}
|
||||
|
||||
fn -is-root []{
|
||||
== (-get uid)[number] 0
|
||||
}
|
||||
|
||||
edit:add-var get-id~ $-get-id~
|
||||
edit:add-var get-uid~ []{ -get uid }
|
||||
edit:add-var get-gid~ []{ -get gid }
|
||||
edit:add-var get-groups~ []{ -get groups; -get groupes }
|
||||
edit:add-var is-root~ $-is-root~
|
|
@ -0,0 +1,19 @@
|
|||
edit:add-var ipinfo~ [@argv]{
|
||||
use moi/util/ip
|
||||
use str
|
||||
|
||||
local:token = (cat $E:HOME/.config/elvish/private/ipinfo_token)
|
||||
|
||||
fn url-of [ip]{
|
||||
str:join '' [ 'ipinfo.io/' $ip '?token=' $token]
|
||||
}
|
||||
|
||||
fn info [ip]{
|
||||
if (ip:is-ip $ip) {
|
||||
local:url = (url-of $ip)
|
||||
echo 'URL: '$url
|
||||
e:curlie $url
|
||||
}
|
||||
}
|
||||
each $info~ $argv
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
edit:add-var ipof~ [@argv]{
|
||||
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:cset (ip:is-ipv4 $e1) 0 (condition:cset (ip:is-ipv6 $e1) 1 2))
|
||||
local:i2 = (condition:cset (ip:is-ipv4 $e2) 0 (condition:cset (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 -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml -resolve (idn -a $d) | peach [l]{
|
||||
local:l = $l
|
||||
local:idx = (+ (str:index $l :) 1)
|
||||
local:value = (str:trim-space $l[$idx".."])
|
||||
if (or (str:has-prefix $l 'IPv4 addresses') (str:has-prefix $l 'IPv6 addresses')) {
|
||||
str:split ', ' $value | peach [e]{
|
||||
local:e = $e
|
||||
if (ip:is-ip $e) {
|
||||
result[ips][$e] = $nil
|
||||
}
|
||||
}
|
||||
} elif (str:has-prefix $l 'TXT records') {
|
||||
result[txt] = $value
|
||||
} elif (str:has-prefix $l 'Resolver') {
|
||||
result[resolvers] = $value
|
||||
} elif (str:has-prefix $l 'Name servers') {
|
||||
result[remote] = (not-eq $value 'name does not exist')
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
} $argv
|
||||
|
||||
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 (and (has-key $remote $d) $remote[$d][remote]) {
|
||||
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
|
||||
} $argv
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
edit:add-var listarchiver~ [@argv]{
|
||||
peach [f]{
|
||||
local:f = $f
|
||||
e:arc ls $f
|
||||
} $argv
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
edit:add-var pdf2grey~ [@argv]{
|
||||
use re
|
||||
use str
|
||||
local:m = [
|
||||
&nb=$false
|
||||
&split=50
|
||||
]
|
||||
|
||||
fn _help []{
|
||||
echo 'Usage: pdf2gray [-hn (<n>)] <input>.pdf <output>.pdf'
|
||||
echo ''
|
||||
echo 'Options:'
|
||||
echo ' -h Affiche cette aide'
|
||||
echo ' -n [0-100] Convertit en noir et blanc. Si un nombre est spécifié, indique le pourcentage de coupure (par défaut: 50)'
|
||||
}
|
||||
|
||||
fn is_pdf [e]{
|
||||
re:match '.*\.pdf$' $e
|
||||
}
|
||||
|
||||
fn is_int [e]{
|
||||
re:match '^\d+$' $e
|
||||
}
|
||||
|
||||
fn is_split [e]{
|
||||
and (>= $e 0) (<= $e 100)
|
||||
}
|
||||
|
||||
while (> (count $argv) 0) {
|
||||
local:e @argv = $@argv
|
||||
if (or (eq $e '-h') (eq $e '--help')) {
|
||||
_help
|
||||
return
|
||||
} elif (eq $e -n) {
|
||||
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
|
||||
if (is_split $e) {
|
||||
m[split] = $e
|
||||
} else {
|
||||
echo 'L’argument (optionnel) après -s doit être compris entre 0 et 100'
|
||||
_help
|
||||
return
|
||||
}
|
||||
}
|
||||
} elif (not (is_pdf $e)) {
|
||||
echo 'Argument non reconnu: '$e
|
||||
_help
|
||||
return
|
||||
} elif (not (has-key $m input)) {
|
||||
m[input] = $e
|
||||
} else {
|
||||
m[output] = $e
|
||||
if (> (count $argv) 0) {
|
||||
echo 'Trop d’arguments: '$@argv
|
||||
_help
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (not (has-key $m input)) {
|
||||
echo 'Manque le input'
|
||||
_help
|
||||
return
|
||||
} elif (not (has-key $m output)) {
|
||||
echo 'Manque le output'
|
||||
_help
|
||||
return
|
||||
}
|
||||
|
||||
local:params = [-colorspace gray]
|
||||
if $m[nb] {
|
||||
@params = (all $params) -threshold $m[split]'%'
|
||||
}
|
||||
@params = $@params $m[input] $m[output]
|
||||
echo 'Commande: convert '(str:join ' ' $params)
|
||||
convert $@params
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
edit:add-var sendsms~ [@argv]{
|
||||
use str
|
||||
|
||||
local:api = https://smsapi.free-mobile.fr/sendmsg
|
||||
local:param = (cat $E:HOME/.config/elvish/private/freesms.json | from-json)
|
||||
local:msg = (str:join '%20' $argv)
|
||||
|
||||
local:url = $api'?user='$param[user]'&pass='$param[password]'&msg='$msg
|
||||
#put $url
|
||||
curl $url
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
edit:add-var trsen~ [@argv]{ e:rlwrap trans -b -t en $@argv }
|
||||
edit:add-var trsfr~ [@argv]{ e:rlwrap trans -b -t fr $@argv }
|
|
@ -0,0 +1,16 @@
|
|||
fn -sync [d1 d2]{
|
||||
rsync -azh --delete --info=progress2,stats ~/.config/$d1/ ~/.config/$d2/
|
||||
}
|
||||
|
||||
fn -save [d]{
|
||||
-sync $d $d.save
|
||||
}
|
||||
|
||||
fn -restore [d]{
|
||||
-sync $d.save $d
|
||||
}
|
||||
|
||||
edit:add-var viv-save~ []{ -save vivaldi }
|
||||
edit:add-var viv-restore~ []{ -restore vivaldi }
|
||||
edit:add-var vivd-save~ []{ -save vivaldi-developer }
|
||||
edit:add-var vivd-restore~ []{ -restore vivaldi-developer }
|
|
@ -0,0 +1,6 @@
|
|||
local:dir = ~/.config/elvish/aliases
|
||||
|
||||
for file [(_ = ?(put $dir/*.elv))] {
|
||||
content = (cat $file | slurp)
|
||||
eval $content
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
local:libdir = $E:HOME/.config/elvish/lib
|
||||
local:builtin_modules = [
|
||||
builtin
|
||||
epm
|
||||
file
|
||||
math
|
||||
path
|
||||
re
|
||||
readline-binding
|
||||
store
|
||||
str
|
||||
unix
|
||||
]
|
||||
|
||||
edit:completion:arg-completer[use] = [@argv]{
|
||||
use str
|
||||
use path
|
||||
all $builtin_modules
|
||||
put $libdir/**.elv | each [f]{
|
||||
if (path:is-regular $f) {
|
||||
str:trim-prefix $f $libdir/
|
||||
}
|
||||
} | each [f]{ str:trim-suffix $f .elv }
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
edit:add-var ++~ [n]{ + $n 1 }
|
||||
edit:add-var --~ [n]{ + $n 1 }
|
||||
|
||||
edit:add-var sign~ [n]{
|
||||
if (> $n 0) {
|
||||
put 1
|
||||
} elif (< $n 0) {
|
||||
put -1
|
||||
} else {
|
||||
put 0
|
||||
}
|
||||
}
|
||||
edit:add-var neg~ [n]{ * $n -1 }
|
||||
edit:add-var abs~ [n]{
|
||||
if (< $n 0) {
|
||||
neg $n
|
||||
} else {
|
||||
put $n
|
||||
}
|
||||
}
|
||||
|
||||
edit:add-var sum~ [@numbers]{
|
||||
local:s = 0
|
||||
each [e]{ s = (+ $s e) } (to-list $numbers)
|
||||
}
|
||||
|
||||
fn -minmax [t @numbers]{
|
||||
local:l = (to-list $@numbers)
|
||||
if (== (count $l) 0) {
|
||||
return
|
||||
}
|
||||
local:m = $l[0]
|
||||
each [n]{
|
||||
if ($t $n $m) {
|
||||
m = $n
|
||||
}
|
||||
} $l[1..]
|
||||
put $m
|
||||
}
|
||||
|
||||
edit:add-var min~ [@numbers]{ -minmax $'<~' $@numbers }
|
||||
edit:add-var max~ [@numbers]{ -minmax $'>~' $@numbers }
|
Loading…
Reference in New Issue