Move pkm alias family to its own function; minor change to vm_inst

This commit is contained in:
mitchell 2022-01-23 13:05:31 -05:00
parent 36aef3ad13
commit 7f0d7d6f6f
3 changed files with 87 additions and 25 deletions

View File

@ -33,31 +33,18 @@ function define_aliases -a uname -d 'Defines aliases for commonly used commands'
# Linux distro specific aliases below # Linux distro specific aliases below
set -l distro #set -l distro
for line in (cat /etc/os-release) #for line in (cat /etc/os-release)
set -l items (string split --max 1 '=' $line) # set -l items (string split --max 1 '=' $line)
if test $items[1] = 'ID' # if test $items[1] = 'ID'
set distro $items[2] # set distro $items[2]
end # end
end #end
switch "$distro" #switch "$distro"
case 'arch' # case 'arch'
alias pkm 'pikaur' # case 'debian'
alias pkmi 'pikaur --sync' #end
alias pkmf 'pikaur --sync --refresh'
alias pkmu 'pikaur --sync --sysupgrade'
alias pkmr 'pikaur -Rsu'
case 'debian'
alias pkm 'apt search'
alias pkmi 'sudo apt install'
alias pkmf 'sudo apt update'
alias pkmu 'sudo apt upgrade; and sudo apt autoremove; and sudo apt autoclean'
function pkmr -d 'Alias for apt uninstall and autoremove'
sudo apt purge $argv; and sudo apt autoremove
end
end
end end

View 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

View File

@ -4,8 +4,10 @@ function vm_inst -a name os_variant install_source
'c/cpus=' \ 'c/cpus=' \
'd/disk-size=' \ 'd/disk-size=' \
'b/bridge=' \ 'b/bridge=' \
s/backing_store \
i/import \ i/import \
n/netboot \ n/netboot \
--ignore-unknown \
-- $argv -- $argv
set -l memory 4096 set -l memory 4096
@ -44,6 +46,10 @@ function vm_inst -a name os_variant install_source
set inst_args $inst_args \ set inst_args $inst_args \
--disk $install_source \ --disk $install_source \
--import --import
else if test -n "$_flag_s"
set inst_args $inst_args \
--disk size=$disk_size,sparse=yes,backing_store=$install_source \
--import
else if test -n "$_flag_n" else if test -n "$_flag_n"
set inst_args $inst_args \ set inst_args $inst_args \
--disk size=$disk_size,sparse=yes \ --disk size=$disk_size,sparse=yes \
@ -54,5 +60,5 @@ function vm_inst -a name os_variant install_source
--cdrom $install_source --cdrom $install_source
end end
virt-install $inst_args virt-install $inst_args $argv
end end