Commit initial
This commit is contained in:
commit
df4f2c07c1
67 changed files with 1781 additions and 0 deletions
38
aliases/archiver.elv
Normal file
38
aliases/archiver.elv
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#alias:new archiver e:archiver
|
||||
fn archiver [@_args]{
|
||||
help = {
|
||||
echo "Usage : archiver [(-zlxgb)] <file to compress>"
|
||||
return
|
||||
}
|
||||
if (or (== (count $_args) 0) (eq $_args[0] -h)) {
|
||||
$help
|
||||
}
|
||||
local:format = zst
|
||||
local:o = $_args[0]
|
||||
if (and (has-prefix $o -) (> (count $o) 1)) {
|
||||
o = $o[1]
|
||||
local:m = [
|
||||
&z=zst
|
||||
&l=lz4
|
||||
&x=xz
|
||||
&g=gzip
|
||||
&b=bz2
|
||||
]
|
||||
if (not (has-key $m $o)) {
|
||||
$help
|
||||
}
|
||||
format = $m[$o]
|
||||
_args = $_args[1:]
|
||||
}
|
||||
if (== (count $_args) 0) {
|
||||
$help
|
||||
}
|
||||
peach [f]{
|
||||
local:f = $f
|
||||
if (eq $f[-1] /) {
|
||||
f = $f[:-1]
|
||||
}
|
||||
e:arc archive $f'.tar.'$format $f
|
||||
echo "'"$f"'" archivé
|
||||
} $_args
|
||||
}
|
||||
16
aliases/bat.elv
Normal file
16
aliases/bat.elv
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#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
|
||||
}
|
||||
17
aliases/br.elv
Normal file
17
aliases/br.elv
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#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
|
||||
}
|
||||
}
|
||||
2
aliases/cat.elv
Normal file
2
aliases/cat.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new cat bat -pp
|
||||
fn cat [@_args]{ bat -pp $@_args }
|
||||
37
aliases/clean_known_hosts.elv
Normal file
37
aliases/clean_known_hosts.elv
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#alias:new clean_known_hosts e:cat
|
||||
fn clean_known_hosts [@_args]{
|
||||
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-ipv4 $e1) 2 (condition:set (ip:is-ipv6 $e1) 1 0))
|
||||
local:i2 = (condition:set (ip:is-ipv4 $e2) 2 (condition:set (ip:is-ipv6 $e2) 1 0))
|
||||
if (!= $i1 $i2) {
|
||||
< $i1 $i2
|
||||
} elif (== $i1 0) {
|
||||
<s $e1 $e2
|
||||
} elif (== $i1 1) {
|
||||
less $ip:cmp6~ $e1 $e2
|
||||
} else {
|
||||
less $ip:cmp4~ $e1 $e2
|
||||
}
|
||||
}
|
||||
|
||||
local:khosts = [&]
|
||||
cat ~/.ssh/known_hosts | eawk [_ hosts @rest]{
|
||||
local:key = (joins ' ' $rest)
|
||||
if (not (has-key $khosts $key)) {
|
||||
khosts[$key] = [&]
|
||||
}
|
||||
splits , $hosts | each [h]{
|
||||
khosts[$key][$h] = $nil
|
||||
}
|
||||
}
|
||||
|
||||
local:lines = [(keys $khosts | each [key]{
|
||||
local:hosts = (keys $khosts[$key] | list:sort $sort-host~ | joins ,)
|
||||
put $hosts $key | joins ' '
|
||||
})]
|
||||
echo (joins "\n" $lines) > ~/.ssh/known_hosts
|
||||
}
|
||||
2
aliases/cp.elv
Normal file
2
aliases/cp.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new cp e:cp -iv
|
||||
fn cp [@_args]{ e:cp -iv $@_args }
|
||||
2
aliases/dcd.elv.tmp
Normal file
2
aliases/dcd.elv.tmp
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new dcd e:broot --only-folder --cmd
|
||||
fn dcd [@_args]{ br --only-folders --cmd (joins ' ' $_args)' :cd' }
|
||||
8
aliases/desarchiver.elv
Normal file
8
aliases/desarchiver.elv
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#alias:new desarchiver e:desarchiver
|
||||
fn desarchiver [@_args]{
|
||||
peach [f]{
|
||||
local:f = $f
|
||||
e:arc unarchive $f
|
||||
echo "'"$f"'" désarchivé
|
||||
} $_args
|
||||
}
|
||||
2
aliases/df.elv
Normal file
2
aliases/df.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new df e:df -h
|
||||
fn df [@_args]{ e:df -h $@_args }
|
||||
2
aliases/diff.elv
Normal file
2
aliases/diff.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new diff e:colordiff
|
||||
fn diff [@_args]{ e:colordiff $@_args }
|
||||
2
aliases/du.elv
Normal file
2
aliases/du.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new du e:du -h
|
||||
fn du [@_args]{ e:du -h $@_args }
|
||||
2
aliases/git.elv
Normal file
2
aliases/git.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new git e:hub
|
||||
fn git [@_args]{ e:hub $@_args }
|
||||
2
aliases/grep.elv
Normal file
2
aliases/grep.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new grep e:grep --color=tty -d skip
|
||||
fn grep [@_args]{ e:grep --color=tty -d skip $@_args }
|
||||
34
aliases/history.elv
Normal file
34
aliases/history.elv
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#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)
|
||||
}
|
||||
}
|
||||
102
aliases/ip-of.elv
Normal file
102
aliases/ip-of.elv
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#alias:new ip-of e:is-ip
|
||||
fn ip-of [@_args]{
|
||||
use str
|
||||
use moi/util/condition
|
||||
use moi/util/ip
|
||||
use moi/util/list
|
||||
|
||||
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] | list:sort $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] | list:sort $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
|
||||
}
|
||||
2
aliases/la.elv
Normal file
2
aliases/la.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#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 }
|
||||
2
aliases/ll.elv
Normal file
2
aliases/ll.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#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 }
|
||||
2
aliases/lla.elv
Normal file
2
aliases/lla.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#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 }
|
||||
2
aliases/ls.elv
Normal file
2
aliases/ls.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#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 }
|
||||
29
aliases/mdig.elv
Normal file
29
aliases/mdig.elv
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#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 "----------------------"
|
||||
}
|
||||
}
|
||||
4
aliases/meteo.elv
Normal file
4
aliases/meteo.elv
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#alias:new meteo e:curl 'wttr.in/?lang=fr'
|
||||
fn meteo [@_args]{
|
||||
curl --connect-timeout 2 "wttr.in/"(joins '' $_args)"?lang=fr"
|
||||
}
|
||||
2
aliases/midi.elv
Normal file
2
aliases/midi.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#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 }
|
||||
2
aliases/mv.elv
Normal file
2
aliases/mv.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new mv e:mv -iv
|
||||
fn mv [@_args]{ e:mv -iv $@_args }
|
||||
4
aliases/pacmanhisto.elv
Normal file
4
aliases/pacmanhisto.elv
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#alias:new pacmanhisto cat /var/log/pacman.log
|
||||
fn pacmanhisto [@_args]{
|
||||
cat /var/log/pacman.log | grep "ALPM" | grep $@_args
|
||||
}
|
||||
2
aliases/pf.elv
Normal file
2
aliases/pf.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new pf e:pkgfile -vri
|
||||
fn pf [@_args]{ e:pkgfile -vri $@_args }
|
||||
11
aliases/publicip.elv
Normal file
11
aliases/publicip.elv
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#alias:new publicip curl ifconfig.co/ip
|
||||
fn publicip {
|
||||
f = [t]{
|
||||
use moi/util/condition
|
||||
t = condition:set (eq $t -6) -6 -4
|
||||
l = condition:set (eq $t -6) 'IPv6: ' 'IPv4: '
|
||||
curl $t ifconfig.co/ip 2> /dev/null | each [ip]{ echo (styled $l bold yellow) $ip }
|
||||
}
|
||||
$f -4
|
||||
$f -6
|
||||
}
|
||||
11
aliases/rename.elv
Normal file
11
aliases/rename.elv
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#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)
|
||||
}
|
||||
}
|
||||
2
aliases/rm.elv
Normal file
2
aliases/rm.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new rm e:rm -Iv
|
||||
fn rm [@_args]{ e:rm -Iv $@_args }
|
||||
2
aliases/timidity.elv
Normal file
2
aliases/timidity.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new timidity e:timidity -a -K -1
|
||||
fn timidity [@_args]{ e:timidity -a -K -1 $@_args }
|
||||
2
aliases/tree.elv
Normal file
2
aliases/tree.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new tree e:tree -puhC --dirsfirst --du -D
|
||||
fn tree [@_args]{ e:tree -puhC --dirsfirst --du -D $@_args }
|
||||
2
aliases/trsen.elv
Normal file
2
aliases/trsen.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new trsen e:rlwrap trans -b -t en
|
||||
fn trsen [@_args]{ e:rlwrap trans -b -t en $@_args }
|
||||
2
aliases/trsfr.elv
Normal file
2
aliases/trsfr.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new trsfr e:rlwrap trans -b -t fr
|
||||
fn trsfr [@_args]{ e:rlwrap trans -b -t fr $@_args }
|
||||
6
aliases/upd.elv
Normal file
6
aliases/upd.elv
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#alias:new upd and ?(mirror-check --fast) (sudo pacman -Syu)
|
||||
fn upd [@_args]{
|
||||
if ?(mirror-check --fast) {
|
||||
sudo pacman -Syu
|
||||
}
|
||||
}
|
||||
2
aliases/vb.elv
Normal file
2
aliases/vb.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new vb e:vim /home/benjamin/.bashrc
|
||||
fn vb [@_args]{ e:vim /home/benjamin/.bashrc $@_args }
|
||||
2
aliases/vc.elv
Normal file
2
aliases/vc.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new vc e:vim /home/benjamin/.vimrc
|
||||
fn vc [@_args]{ e:vim /home/benjamin/.vimrc $@_args }
|
||||
2
aliases/vf.elv
Normal file
2
aliases/vf.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new vf e:vim /home/benjamin/.config/config.fish
|
||||
fn vf [@_args]{ e:vim /home/benjamin/.config/config.fish $@_args }
|
||||
2
aliases/vi.elv
Normal file
2
aliases/vi.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new vi e:vim
|
||||
fn vi [@_args]{ e:vim $@_args }
|
||||
2
aliases/vp.elv
Normal file
2
aliases/vp.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new vp e:vim PKGBUILD
|
||||
fn vp [@_args]{ e:vim PKGBUILD $@_args }
|
||||
2
aliases/vv.elv
Normal file
2
aliases/vv.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new vv e:vim -R
|
||||
fn vv [@_args]{ e:vim -R $@_args }
|
||||
2
aliases/vz.elv
Normal file
2
aliases/vz.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new vz e:vim /home/benjamin/.zshrc
|
||||
fn vz [@_args]{ e:vim /home/benjamin/.zshrc $@_args }
|
||||
2
aliases/youtube-dl.elv
Normal file
2
aliases/youtube-dl.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new youtube-dl e:youtube-dl --no-check-certificate
|
||||
fn youtube-dl [@_args]{ e:youtube-dl --no-check-certificate $@_args }
|
||||
2
aliases/youtube_audio.elv
Normal file
2
aliases/youtube_audio.elv
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#alias:new youtube_audio youtube-dl -x --audio-format best
|
||||
fn youtube_audio [@_args]{ youtube-dl -x --audio-format best $@_args }
|
||||
Loading…
Add table
Add a link
Reference in a new issue