Refonte des aliases
This commit is contained in:
parent
817650ded9
commit
b3d74ce2d7
|
@ -1,33 +0,0 @@
|
|||
edit:add-var addbadips~ {|@argv|
|
||||
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
|
||||
|
||||
fn add {|f cmp ips t|
|
||||
var @cips = (cat $f)
|
||||
var m c = (map:to-set $cips) 0
|
||||
each {|e|
|
||||
if (not (has-key $m $e)) {
|
||||
set m[$e] = $nil
|
||||
set @cips = $@cips $e
|
||||
set c = (+ $c 1)
|
||||
echo $e ajoutée
|
||||
}
|
||||
} $ips
|
||||
if (> $c 0) {
|
||||
set @cips = (list:sort $cmp $cips)
|
||||
echo (str:join "\n" $cips) > $f
|
||||
}
|
||||
printf "%d %s ajoutées (%d au total)\n" $c $t (count $cips)
|
||||
}
|
||||
|
||||
|
||||
var ip4 ip6 = (list:filter $ip:is-ip~ $argv | list:unzip {|_ ip| ip:is-ipv4 $ip})
|
||||
if (list:is-not-empty $ip4) {
|
||||
add $E:HOME/ips/bad_ips.txt $ip:comp4~ $ip4 IPv4s
|
||||
}
|
||||
if (list:is-not-empty $ip6) {
|
||||
add $E:HOME/ips/bad_ipsv6.txt $ip:comp6~ $ip6 IPv6s
|
||||
}
|
||||
}
|
|
@ -3,20 +3,19 @@ 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 diff~ $e:delta~
|
||||
edit:add-var dig~ {|@argv| e:dig +noall +answer $@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 }
|
||||
fn -erd {|@argv| e:erd -HlI --dir-order last --sort name --layout inverted $@argv }
|
||||
#edit:add-var erd~ $-erd~
|
||||
#edit:add-var git~ $e:hub~
|
||||
edit:add-var grep~ {|@argv| e:grep --color=tty -d skip $@argv }
|
||||
#edit:add-var grep~ {|@argv| e:ack $@argv }
|
||||
edit:add-var hx~ {|@argv| e:helix $@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 rename~ {|@argv| /home/benjamin/bin/rename $@argv }
|
||||
edit:add-var sudo~ {|@argv| fail 'Use doas instead'}
|
||||
edit:add-var timidity~ {|@argv| e:timidity -a -K -1 $@argv }
|
||||
edit:add-var trdsql~ {|@argv| e:trdsql -ih -id ';' -omd $@argv }
|
||||
|
|
|
@ -34,7 +34,7 @@ fn -copt {||
|
|||
doas find /opt -maxdepth 3 -type f 2>/dev/null | each $-check-executable~
|
||||
}
|
||||
|
||||
edit:add-var checklinks~ {||
|
||||
edit:add-var check-links~ {||
|
||||
-cbin
|
||||
-clib
|
||||
-copt
|
|
@ -1,4 +1,4 @@
|
|||
edit:add-var cleankh~ {|@argv|
|
||||
edit:add-var clean-known-hosts~ {|@argv|
|
||||
use re
|
||||
use str
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
|
@ -1,4 +1,4 @@
|
|||
edit:add-var commitkcp~ {|@argv|
|
||||
edit:add-var commit-kcp~ {|@argv|
|
||||
use str
|
||||
|
||||
var m = [
|
|
@ -1,4 +1,4 @@
|
|||
edit:add-var digall~ {|@argv|
|
||||
edit:add-var dig-all~ {|@argv|
|
||||
use re
|
||||
use str
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
|
@ -1,17 +0,0 @@
|
|||
use str
|
||||
|
||||
edit:add-var grawlix~ {|@argv|
|
||||
var @chars = (str:split '' '#$%&*+=^~£§¶±÷≠Ω√∆◊')
|
||||
var nbChars = (count $chars)
|
||||
var length = (shuf -i 4-7 -n 1)
|
||||
var graw = []
|
||||
|
||||
range $length | each {|_|
|
||||
var ci = (shuf -i 1-$nbChars -n 1)
|
||||
set @graw = $@graw $chars[(- $ci 1)]
|
||||
}
|
||||
|
||||
set @graw = $@graw '!'
|
||||
|
||||
echo (str:join '' $graw)
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
edit:add-var ipinfo~ {|@argv|
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
|
||||
|
||||
var token = (cat $E:HOME/.config/elvish/private/ipinfo_token)
|
||||
|
||||
fn url-of {|ip|
|
||||
printf 'ipinfo.io/%s?token=%s' $ip $token
|
||||
}
|
||||
|
||||
fn info {|ip|
|
||||
if (ip:is-ip $ip) {
|
||||
var url = (url-of $ip)
|
||||
printf "URL: %s\n" $url
|
||||
e:curlie $url
|
||||
}
|
||||
}
|
||||
each $info~ $argv
|
||||
}
|
|
@ -1,4 +1,58 @@
|
|||
edit:add-var ipof~ {|@argv|
|
||||
edit:add-var add-badips~ {|@argv|
|
||||
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
|
||||
|
||||
fn add {|f cmp ips t|
|
||||
var @cips = (cat $f)
|
||||
var m c = (map:to-set $cips) 0
|
||||
each {|e|
|
||||
if (not (has-key $m $e)) {
|
||||
set m[$e] = $nil
|
||||
set @cips = $@cips $e
|
||||
set c = (+ $c 1)
|
||||
echo $e ajoutée
|
||||
}
|
||||
} $ips
|
||||
if (> $c 0) {
|
||||
set @cips = (list:sort $cmp $cips)
|
||||
echo (str:join "\n" $cips) > $f
|
||||
}
|
||||
printf "%d %s ajoutées (%d au total)\n" $c $t (count $cips)
|
||||
}
|
||||
|
||||
|
||||
var ip4 ip6 = (list:filter $ip:is-ip~ $argv | list:unzip {|_ ip| ip:is-ipv4 $ip})
|
||||
if (list:is-not-empty $ip4) {
|
||||
add $E:HOME/ips/bad_ips.txt $ip:comp4~ $ip4 IPv4s
|
||||
}
|
||||
if (list:is-not-empty $ip6) {
|
||||
add $E:HOME/ips/bad_ipsv6.txt $ip:comp6~ $ip6 IPv6s
|
||||
}
|
||||
}
|
||||
|
||||
edit:add-var ip-info~ {|@argv|
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/ip
|
||||
|
||||
var token = (cat $E:HOME/.config/elvish/private/ipinfo_token)
|
||||
|
||||
fn url-of {|ip|
|
||||
printf 'ipinfo.io/%s?token=%s' $ip $token
|
||||
}
|
||||
|
||||
fn info {|ip|
|
||||
if (ip:is-ip $ip) {
|
||||
var url = (url-of $ip)
|
||||
printf "URL: %s\n" $url
|
||||
e:curlie $url
|
||||
}
|
||||
}
|
||||
|
||||
each $info~ $argv
|
||||
}
|
||||
|
||||
edit:add-var ip-of~ {|@argv|
|
||||
use re
|
||||
use str
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
||||
|
@ -100,3 +154,14 @@ edit:add-var ipof~ {|@argv|
|
|||
echo
|
||||
} $argv
|
||||
}
|
||||
|
||||
edit:add-var ip-public~ {|@argv|
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
||||
var f = {|t|
|
||||
var l = (common:cond (eq $t -6) 'IPv6: ' 'IPv4: ')
|
||||
e:curl $t ifconfig.co/ip 2> /dev/null | each {|ip| echo (styled $l bold yellow) $ip}
|
||||
}
|
||||
$f -4
|
||||
$f -6
|
||||
}
|
||||
|
|
@ -1,6 +1,10 @@
|
|||
edit:add-var meteo~ {|@argv|
|
||||
use str
|
||||
var url = (printf 'wttr.in/%s?lang=fr' (str:join '' $argv))
|
||||
var city = 'Montbéliard'
|
||||
if (> (count $argv) 0) {
|
||||
set city = (str:join '' $argv)
|
||||
}
|
||||
var url = (printf 'wttr.in/%s?lang=fr' $city)
|
||||
#curl --connect-timeout 2 $url
|
||||
e:curlie -s --connect-timeout 2 $url
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
edit:add-var pacman-histo~ {|@argv| e:cat /var/log/pacman.log | e:rg "ALPM" | e:rg $@argv }
|
||||
|
||||
edit:add-var upd~ {|@args|
|
||||
if ?(mirror-check --fast) {
|
||||
doas pacman -Syu
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
edit:add-var pacmanhisto~ {|@argv| e:cat /var/log/pacman.log | e:rg "ALPM" | e:rg $@argv }
|
|
@ -1,9 +0,0 @@
|
|||
edit:add-var publicip~ {|@argv|
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/common
|
||||
var f = {|t|
|
||||
var l = (common:cond (eq $t -6) 'IPv6: ' 'IPv4: ')
|
||||
e:curl $t ifconfig.co/ip 2> /dev/null | each {|ip| echo (styled $l bold yellow) $ip}
|
||||
}
|
||||
$f -4
|
||||
$f -6
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
edit:add-var genstr~ {|@argv|
|
||||
edit:add-var gen-str~ {|@argv|
|
||||
use re
|
||||
use str
|
||||
|
||||
|
@ -65,3 +65,21 @@ edit:add-var genstr~ {|@argv|
|
|||
echo
|
||||
}
|
||||
}
|
||||
|
||||
edit:add-var grawlix~ {|@argv|
|
||||
use str
|
||||
|
||||
var @chars = (str:split '' '#$%&*+=^~£§¶±÷≠Ω√∆◊')
|
||||
var nbChars = (count $chars)
|
||||
var length = (shuf -i 4-7 -n 1)
|
||||
var graw = []
|
||||
|
||||
range $length | each {|_|
|
||||
var ci = (shuf -i 1-$nbChars -n 1)
|
||||
set @graw = $@graw $chars[(- $ci 1)]
|
||||
}
|
||||
|
||||
set @graw = $@graw '!'
|
||||
|
||||
echo (str:join '' $graw)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
edit:add-var sendsms~ {|@argv|
|
||||
edit:add-var send-sms~ {|@argv|
|
||||
use str
|
||||
|
||||
var api = https://smsapi.free-mobile.fr/sendmsg
|
|
@ -1,21 +0,0 @@
|
|||
var domain = https://transfer.hostux.net/
|
||||
edit:add-var transfer~ {|@argv|
|
||||
use path
|
||||
if (not-eq (count $argv) 0) {
|
||||
fail('Usage: transfer <fichier_ou_repertoire>')
|
||||
}
|
||||
var file = $argv[0]
|
||||
var filename = (basename $file)
|
||||
var is_dir = (path:is-dir &follow-symlink=$true $file)
|
||||
var is_regular = (path:is-regular &follow-symlink=$true $file)
|
||||
if (not (and is_dir is_regular)) {
|
||||
fail("'"$file"' n’existe pas")
|
||||
}
|
||||
if is_dir {
|
||||
set filename = $filename'.tar.gz'
|
||||
cd $file
|
||||
tar -c . | e:curl --progress-bar --upload-file - $domain$filename | tee /dev/null
|
||||
} else {
|
||||
cat $file | e:curl --progress-bar --upload-file - $domain$filename | teee /dev/null
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
edit:add-var trsen~ {|@argv| e:rlwrap trans -b -t en $@argv }
|
||||
edit:add-var trsfr~ {|@argv| e:rlwrap trans -b -t fr $@argv }
|
|
@ -1,6 +0,0 @@
|
|||
edit:add-var upd~ {|@args|
|
||||
if ?(mirror-check --fast) {
|
||||
doas pacman -Syu
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
var app = 'helix'
|
||||
var app = 'nvim'
|
||||
|
||||
var editors = [
|
||||
&emac=[
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
fn -aliases {||
|
||||
use re
|
||||
use str
|
||||
|
||||
e:cat $E:HOME/.config/elvish/aliases/*.elv | e:rg '^edit:add-var' | re:awk {|_ _ alias @_|
|
||||
str:replace '~' '' $alias
|
||||
} | order
|
||||
}
|
||||
|
||||
edit:add-var aliases~ {|| -aliases | each {|e| echo $e } }
|
||||
|
||||
edit:add-var which-all~ {|argv|
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
||||
use path
|
||||
use os
|
||||
use str
|
||||
|
||||
if (-aliases | list:contains $argv) {
|
||||
echo '(Alias)'
|
||||
}
|
||||
|
||||
str:split ':' $E:PATH | each {|p|
|
||||
var f = (path:join $p $argv)
|
||||
if (os:is-regular $f) {
|
||||
echo $f
|
||||
}
|
||||
}
|
||||
}
|
10
rc.elv
10
rc.elv
|
@ -1,12 +1,12 @@
|
|||
#set-env BAT_THEME Coldark-Cold
|
||||
set-env BAT_PAGER 'less -RF'
|
||||
set-env EXA_COLORS 'da=36:*.pdf=4:*.doc=4:*.xls=4:*.docx=4:*.xlsx=4:*.odt=4:*.ods=4'
|
||||
#set-env EDITOR nvim
|
||||
set-env EDITOR vim
|
||||
#set-env EDITOR vim
|
||||
set-env EDITOR nvim
|
||||
#set-env EDITOR kak
|
||||
#set-env EDITOR hx
|
||||
#set-env VISUAL 'nvim -R'
|
||||
set-env VISUAL 'vim -R'
|
||||
#set-env VISUAL 'vim -R'
|
||||
set-env VISUAL 'nvim -R'
|
||||
#set-env VISUAL 'kak -ro'
|
||||
#set-env VISUAL hx
|
||||
set-env CURRENT_SHELL 'elvish'
|
||||
|
@ -14,7 +14,7 @@ set-env STARSHIP_CONFIG ~/.config/starship/starship.toml
|
|||
set-env PERL5LIB /home/benjamin/perl5/lib/perl5
|
||||
set-env NODE_OPTIONS --openssl-legacy-provider
|
||||
set-env QSV_SNIFF_DELIMITER 1
|
||||
set @paths = $@paths /home/benjamin/bin /home/benjamin/Go/bin /home/benjamin/perl5/bin
|
||||
set @paths = /home/benjamin/{bin,Go/bin,perl5/bin} $@paths
|
||||
|
||||
{
|
||||
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
||||
|
|
Loading…
Reference in New Issue