mirror of
https://github.com/mitchell/dotfiles.git
synced 2025-12-17 20:37:22 +00:00
Move pkm alias family to its own function; minor change to vm_inst
This commit is contained in:
parent
36aef3ad13
commit
7f0d7d6f6f
3 changed files with 87 additions and 25 deletions
69
.config/fish/functions/pkm.fish
Normal file
69
.config/fish/functions/pkm.fish
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
function pkm -a command -d 'Shortcuts for pacman and apt'
|
||||
set -l distro
|
||||
|
||||
for line in (cat /etc/os-release)
|
||||
set -l items (string split --max 1 '=' $line)
|
||||
|
||||
if test $items[1] = ID
|
||||
set distro $items[2]
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
set -l pkm
|
||||
|
||||
switch $distro
|
||||
case arch
|
||||
if command -q pikaur
|
||||
_pacman_commander pikaur $argv
|
||||
else
|
||||
_pacman_commander 'sudo pacman' $argv
|
||||
end
|
||||
case debian
|
||||
_apt_commander 'sudo apt' $argv
|
||||
end
|
||||
end
|
||||
|
||||
function _pacman_commander -a pkm command
|
||||
set -l args $argv[3..]
|
||||
|
||||
switch $command
|
||||
case i install
|
||||
$pkm --sync $args
|
||||
case f fetch
|
||||
reflector --latest 50 --fastest 3 --sort age --protocol https --thread 4 |
|
||||
sudo tee /etc/pacman.d/mirrorlist
|
||||
and $pkm --sync --refresh
|
||||
case u update
|
||||
$pkm --sync --sysupgrade $args
|
||||
and sudo env DIFFPROG='nvim -d' checkservices
|
||||
case r remove
|
||||
$pkm --remove --recursive --unneeded $args
|
||||
case s search
|
||||
$pkm $args
|
||||
case '*'
|
||||
$pkm $command $args
|
||||
end
|
||||
end
|
||||
|
||||
function _apt_commander -a pkm command
|
||||
set -l args $argv[3..]
|
||||
|
||||
switch $command
|
||||
case i install
|
||||
$pkm install $args
|
||||
case f fetch
|
||||
$pkm update
|
||||
case u update
|
||||
$pkm upgrade $args
|
||||
and $pkm autoremove
|
||||
and $pkm autoclean
|
||||
case r remove
|
||||
$pkm purge $args
|
||||
and $pkm autoremove
|
||||
case s search
|
||||
$pkm search $args
|
||||
case '*'
|
||||
$pkm $command $args
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue