mirror of https://github.com/mitchell/dotfiles.git
Move pkm alias family to its own function; minor change to vm_inst
This commit is contained in:
parent
36aef3ad13
commit
7f0d7d6f6f
|
@ -33,31 +33,18 @@ function define_aliases -a uname -d 'Defines aliases for commonly used commands'
|
|||
|
||||
# Linux distro specific aliases below
|
||||
|
||||
set -l distro
|
||||
#set -l distro
|
||||
|
||||
for line in (cat /etc/os-release)
|
||||
set -l items (string split --max 1 '=' $line)
|
||||
#for line in (cat /etc/os-release)
|
||||
# set -l items (string split --max 1 '=' $line)
|
||||
|
||||
if test $items[1] = 'ID'
|
||||
set distro $items[2]
|
||||
end
|
||||
end
|
||||
# if test $items[1] = 'ID'
|
||||
# set distro $items[2]
|
||||
# end
|
||||
#end
|
||||
|
||||
switch "$distro"
|
||||
case 'arch'
|
||||
alias pkm 'pikaur'
|
||||
alias pkmi 'pikaur --sync'
|
||||
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
|
||||
#switch "$distro"
|
||||
# case 'arch'
|
||||
# case 'debian'
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -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
|
|
@ -4,8 +4,10 @@ function vm_inst -a name os_variant install_source
|
|||
'c/cpus=' \
|
||||
'd/disk-size=' \
|
||||
'b/bridge=' \
|
||||
s/backing_store \
|
||||
i/import \
|
||||
n/netboot \
|
||||
--ignore-unknown \
|
||||
-- $argv
|
||||
|
||||
set -l memory 4096
|
||||
|
@ -44,6 +46,10 @@ function vm_inst -a name os_variant install_source
|
|||
set inst_args $inst_args \
|
||||
--disk $install_source \
|
||||
--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"
|
||||
set inst_args $inst_args \
|
||||
--disk size=$disk_size,sparse=yes \
|
||||
|
@ -54,5 +60,5 @@ function vm_inst -a name os_variant install_source
|
|||
--cdrom $install_source
|
||||
end
|
||||
|
||||
virt-install $inst_args
|
||||
virt-install $inst_args $argv
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue