Compare commits

..

10 Commits

14 changed files with 268 additions and 100 deletions

4
aliases/49.3.elv Normal file
View File

@ -0,0 +1,4 @@
var cmd = $e:doas~
#var cmd = $e:sudo~
edit:add-var 49.3~ {|@argv| $cmd $@argv }

View File

@ -1,11 +1,11 @@
edit:add-var adguard~ {|@argv|
use str
sudo chattr -i /etc/resolv.conf
doas chattr -i /etc/resolv.conf
var beg = 's|^.*\(192\.168\.0\.25\)|'
var end = 'nameserver \1|'
if (and (> (count $argv) 0) (str:has-prefix $argv[0] u)) {
set end = '# '$end
}
sudo sed -i $beg$end /etc/resolv.conf
sudo chattr +i /etc/resolv.conf
doas sed -i $beg$end /etc/resolv.conf
doas chattr +i /etc/resolv.conf
}

View File

@ -7,13 +7,19 @@ 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 TXT MX NS SOA $@argv }
edit:add-var du~ {|@argv| e:du -h $@argv }
fn -erd {|@argv| e:erd -HlI --dirs-first $@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 sudo~ {|@argv| fail 'Use doas instead'}
edit:add-var timidity~ {|@argv| e:timidity -a -K -1 $@argv }
edit:add-var tree~ {|@argv| e:tree -puhC --dirsfirst --du -D $@argv }
edit:add-var wget~ {|@argv| e:wget2 $@argv }
#edit:add-var tree~ {|@argv| e:tree -puhC --dirsfirst --du -D $@argv }
edit:add-var tree~ $-erd~
edit:add-var ungron~ {|@argv| e:gron --ungron $@argv }
#edit:add-var wget~ {|@argv| e:wget2 $@argv }

View File

@ -3,7 +3,7 @@ use str
fn -check {|f|
use str
var @missings = (try {
sudo ldd $f 2>/dev/null | grep 'not found' | eawk {|_ m @_| put $m }
doas ldd $f 2>/dev/null | grep 'not found' | eawk {|_ m @_| put $m }
} catch e {
})
if (> (count $missings) 1) {
@ -20,17 +20,17 @@ fn -check-executable {|f|
fn -cbin {||
echo (styled 'Searching broken binaries…' bold bright-yellow)
sudo find /usr/bin -maxdepth 1 -type f 2>/dev/null | each $-check~
doas find /usr/bin -maxdepth 1 -type f 2>/dev/null | each $-check~
}
fn -clib {||
echo (styled 'Searching broken libs…' bold bright-yellow)
sudo find /usr/lib/*.so* -maxdepth 1 -type f 2>/dev/null | each $-check-executable~
doas find /usr/lib/*.so* -maxdepth 1 -type f 2>/dev/null | each $-check-executable~
}
fn -copt {||
echo (styled 'Searching broken binariess in opt…' bold bright-yellow)
sudo find /opt -maxdepth 3 -type f 2>/dev/null | each $-check-executable~
doas find /opt -maxdepth 3 -type f 2>/dev/null | each $-check-executable~
}
edit:add-var checklinks~ {||

View File

@ -15,6 +15,6 @@ edit:add-var commitkcp~ {|@argv|
set msg = (printf '%s - %s' $msg (str:join ' ' $argv))
}
printf "git commit -am '%s'; git push" $msg
printf "git commit -am '%s'; git push\n" $msg
git commit -am $msg; git push
}

17
aliases/grawlix.elv Normal file
View File

@ -0,0 +1,17 @@
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)
}

View File

@ -6,9 +6,21 @@ fn -go-ls {|@argv|
e:go-ls --group-directories-first -T '+%Y.%m.%d %H:%M' --git $@argv
}
var cmd = $-go-ls~
fn -exa {|@argv|
e:exa --color auto --git --icons --group-directories-first $@argv
}
fn -exal {|@argv|
-exa -lghH@ --time-style long-iso $@argv
}
var cmd = $-exa~
var cmdl = $-exal~
edit:add-var ls~ {|@argv| $cmd $@argv }
edit:add-var la~ {|@argv| $cmd -a $@argv }
edit:add-var ll~ {|@argv| $cmd -lh $@argv }
edit:add-var lla~ {|@argv| $cmd -lha $@argv }
#edit:add-var la~ {|@argv| $cmd -a $@argv }
#edit:add-var ll~ {|@argv| $cmd -lh $@argv }
#edit:add-var lla~ {|@argv| $cmd -lha $@argv }
edit:add-var la~ {|@argv| $cmd -aa $@argv }
edit:add-var ll~ {|@argv| $cmdl -l $@argv }
edit:add-var lla~ {|@argv| $cmdl -aa $@argv }

View File

@ -1,66 +0,0 @@
edit:add-var maj-symfony~ {|@argv|
var repo = symfony-cli/symfony-cli
var bin = /usr/local/bin/symfony
var tmp = (mktemp -u /tmp/symfony.XXXXXXXX)
var cdir = (pwd)
fn lastVersion {||
try {
curl -s (printf 'https://api.github.com/repos/%s/releases/latest' $repo) | grep 'tag_name' | awk '{print substr($2, 3, length($2)-4) }'
} catch e {
fail 'Impossible de récupérer les infos sur la dernière version'
}
}
fn currentVersion {||
$bin -V --no-ansi | awk '{print $4}'
}
fn download {|version|
mkdir $tmp
cd $tmp
try {
#wget -O symfony.tar.gz (printf 'https://github.com/%s/archive/refs/tags/v%s.tar.gz' $repo $version)
wget -O symfony.tar.gz (printf 'https://github.com/%s/releases/download/v%s/symfony-cli_linux_amd64.tar.gz' $repo $version)
tar -xzf symfony.tar.gz
} catch e {
cd $cdir
rm -rf $tmp
fail (printf 'Impossible de récupérer symfony %s' $version)
}
}
fn install {|version|
#cd (printf '%s/symfony-cli-%s' $tmp $version)
#go mod vendor
#go build -mod=vendor -o symfony main.go
cd $tmp
cp -fa $bin{,.old}
cp -fa symfony $bin
}
fn info {|msg|
echo (styled $msg bold yellow)
}
fn error {|msg|
echo (styled $msg bold red)
}
var cv = (currentVersion)
var lv = (lastVersion)
if (eq $cv $lv) {
info (printf 'Vous avez la dernière version de symfony (%s)' $cv)
return
}
info (printf 'Récupération de symfony %s' $lv)
download $lv
info (printf 'Mise à jour de symfony %s vers %s' $cv $lv)
install $lv
cd $cdir
rm -rf $tmp
}

21
aliases/transfer.elv Normal file
View File

@ -0,0 +1,21 @@
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"' nexiste 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
}
}

View File

@ -1,6 +1,6 @@
edit:add-var upd~ {|@args|
if ?(mirror-check --fast) {
sudo pacman -Syu
doas pacman -Syu
}
}

View File

@ -1,14 +1,53 @@
var cmd = $e:vim~
#var cmd = $e:kak~
#var cmd = $e:emacs~
var app = 'nvim'
edit:add-var vi~ {|@argv| $cmd $@argv }
edit:add-var vb~ {|@argv| $cmd $@argv ~/.bashrc }
edit:add-var vc~ {|@argv| $cmd $@argv ~/.vimrc }
edit:add-var ve~ {|@argv| $cmd $@argv ~/.config/elvish/rc.elv }
edit:add-var vf~ {|@argv| $cmd $@argv ~/.config/fish/config.fish }
edit:add-var vp~ {|@argv| $cmd $@argv PKGBUILD }
edit:add-var vv~ {|@argv| $cmd -R $@argv } # vim/nvim
#edit:add-var vv~ {|@argv| $cmd -ro $@argv } # kak
#edit:add-var vv~ {|@argv| $cmd $@argv --eval '(setq buffer-read-only t)' } # emacs
edit:add-var vz~ {|@argv| $cmd $@argv ~/.zshrc }
var editors = [
&emac=[
&e={|@argv| e:emacs $@argv }
&v={|@argv| e:emacs $@argv --eval '(setq buffer-read-only)' }
]
&helix=[
&e={|@argv| e:helix $@argv }
&v={|@argv| e:helix $@argv } # Pas de lecture seule actuellement
]
&kak=[
&e={|@argv| e:kak $@argv }
&v={|@argv| e:kak -ro $@argv }
]
&nvim=[
&e={|@argv| e:nvim $@argv }
&v={|@argv| e:nvim -R $@argv }
]
&vim=[
&e={|@argv| e:vim $@argv }
&v={|@argv| e:vim -R $@argv }
]
]
var ce~ = $editors[$app]['e']
var cv~ = $editors[$app]['v']
# ÉDITEURS DISPOS
#fn ce {|@argv| e:emacs $@argv }
#fn ce {|@argv| e:helix $@argv }
#fn ce {|@argv| e:kak $@argv }
#fn ce {|@argv| e:nvim $@argv }
#fn ce {|@argv| e:vim $@argv }
# LECTURE SEULE
## emacs
#fn cv {|@argv| ce $@argv --eval '(setq buffer-read-only)' }
## helix (pas le lecture seule pour le moment)
#fn cv {|@argv| ce $@argv }
## kak
#fn cv {|@argv| ce -ro $@argv }
# nvim/vim
#fn cv {|@argv| ce -R $@argv }
edit:add-var vi~ $ce~
edit:add-var vb~ {|@argv| ce $@argv ~/.bashrc }
edit:add-var vc~ {|@argv| ce $@argv ~/.vimrc }
edit:add-var ve~ {|@argv| ce $@argv ~/.config/elvish/rc.elv }
edit:add-var vf~ {|@argv| ce $@argv ~/.config/fish/config.fish }
edit:add-var vp~ {|@argv| ce $@argv PKGBUILD }
edit:add-var vv~ $cv~
edit:add-var vz~ {|@argv| ce $@argv ~/.zshrc }

132
aliases/vpn.elv Normal file
View File

@ -0,0 +1,132 @@
use str
use framagit.org/benjamin.vaudour/elv-lib/mods/list
var vpnType = [
&wireguard=$nil
&vpn=$nil
]
var shortcut = [
&ca=ca.kaosx.cf
&fr=fr.kaosx.cf
&lu=luence-wg
&lu2=luence-ovpn
&cli=luence-client
&nl=proton_nl5
&jp=proton_jp2
&us=proton_us3
]
var next = [
&ca.kaosx.cf=fr.kaosx.cf
&fr.kaosx.cf=luence-wg
&luence-wg=luence-client
&luence-ovpn=luence-client
# &luence-client=proton_nl5
# &proton_nl5=proton_us3
# &proton_us3=proton_jp2
]
fn -list {|&active=$false|
var @argv = connection show
if $active {
set @argv = $@argv --active
}
nmcli $@argv | eawk {|_ @name uuid tpe dev|
if (has-key $vpnType $tpe) {
str:join ' ' $name
}
}
}
fn -up {|name|
nmcli connection up $name
}
fn -down {|name|
nmcli connection down $name
}
fn -active {||
-list &active=$true
}
fn -is-active {|name|
-active | list:contains $name
}
fn -next {||
var @n = (-active | list:first {|e| has-key $next $e })
if (== 1 (count $n)) {
put $next[$n[0]]
} else {
put ca.kaosx.cf
}
}
fn -vpn-stop {||
var @a = (-active)
if (== (count $a) 0) {
echo 'Aucune connexion active'
} else {
-active | each $-down~
}
}
fn -vpn-start {|name|
if (has-key $shortcut $name) {
set name = $shortcut[$name]
}
if (not (-list | list:contains $name)) {
printf "Le VPN “%s” nèxiste pas\n" $name
} else {
-active | each $-down~
-up $name
}
}
fn -vpn-list {||
var @act = (-active)
-list | each {|n|
if (list:contains $n $act) {
echo (styled $n green)
} else {
echo $n
}
}
}
fn -vpn-help {||
echo 'vpn: Active ou désactive les connections VPN'
echo 'Usage:'
echo ' help Affiche cette aide'
echo ' list Liste les VPN disponibles'
echo ' stop Arrête toutes les connexions VPN actives'
echo ' <vpn> Active la connexion VPN donnée et désactive les autres'
echo ' (sans argument) Active la prochaine connexion VPN et désactive les autres'
}
fn -vpn {||
-vpn-start (-next)
}
edit:add-var vpn~ {|@argv|
var c = (count $argv)
if (== $c 0) {
-vpn
} elif (!= $c 1) {
-vpn-help
fail 'Arguments invalides'
} else {
var e = $argv[0]
if (eq $e help) {
-vpn-help
} elif (eq $e list) {
-vpn-list
} elif (eq $e stop) {
-vpn-stop
} else {
-vpn-start $e
}
}
}

View File

@ -1,16 +1,13 @@
var cmd = $e:yt-dlp~
#var cmd = $e:youtube-dl~
fn -dl {|@argv|
$cmd --no-check-certificate $@argv
$cmd --no-check-certificate $@argv
}
fn -audio {|@argv|
-dl -x --audio-format best $@argv
}
edit:add-var youtube-dl~ {|@argv| -dl $@argv }
edit:add-var youtube-audio~ {|@argv| -audio $@argv }
edit:add-var yt-dl~ {|@argv| -dl $@argv }
edit:add-var yt-audio~ {|@argv| -audio $@argv }

10
rc.elv
View File

@ -1,10 +1,16 @@
#set-env BAT_THEME Coldark-Cold
set-env BAT_PAGER 'less -RF'
set-env EDITOR vim
set-env VIEW 'vim -R'
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 kak
#set-env EDITOR hx
set-env VISUAL 'nvim -R'
#set-env VISUAL 'kak -ro'
#set-env VISUAL hx
set-env CURRENT_SHELL 'elvish'
set-env STARSHIP_CONFIG ~/.config/starship/starship.toml
set-env PERL5LIB /home/benjamin/perl5/lib/perl5
set-env NODE_OPTIONS --openssl-legacy-provider
set @paths = $@paths /home/benjamin/bin /home/benjamin/Go/bin /home/benjamin/perl5/bin
{