From a81fa84682e7b6cd056005bf6ba82c12a5aeeb92 Mon Sep 17 00:00:00 2001 From: Tobias Heinlein Date: Sat, 17 Dec 2022 11:38:41 +0100 Subject: [PATCH] FEAT: Add Aptitude aliases Why?: - Aptitude is an alternative to apt with a great user interface, so there should also be some aliases that make using it as easy as with the apt aliases. This change addresses the need by: - Add new alias file aptitude.aliases.bash with most of the same Apt aliases instead using Aptitude - Also add some new aliases for Aptitude specific features like "why-not" --- aliases/available/aptitude.aliases.bash | 32 +++++++++++++++++++++++++ test/completion/bash-it.completion.bats | 8 +++---- 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 aliases/available/aptitude.aliases.bash diff --git a/aliases/available/aptitude.aliases.bash b/aliases/available/aptitude.aliases.bash new file mode 100644 index 00000000..47c5cc01 --- /dev/null +++ b/aliases/available/aptitude.aliases.bash @@ -0,0 +1,32 @@ +# shellcheck shell=bash +# +# -binaryanomaly + +cite 'about-alias' +about-alias 'Aptitude and dpkg aliases for Ubuntu and Debian distros.' + +# set apt aliases +function _set_pkg_aliases() { + if _command_exists aptitude; then + alias apts='aptitude search' + alias aptshow='aptitude show' + alias aptinst='sudo aptitude install -V' + alias aptupd='sudo aptitude update' + alias aptsupg='sudo aptitude safe-upgrade' + alias aptupg='sudo apt-get dist-upgrade -V && sudo apt-get autoremove' + alias aptupgd='sudo apt-get update && sudo apt-get dist-upgrade -V && sudo apt-get autoremove' + alias aptrm='sudo aptitude remove' + alias aptpurge='sudo aptitude purge' + alias aptclean='sudo aptitude clean && sudo aptitude autoclean' + alias apty='aptitude why' + alias aptyn='aptitude why-not' + + alias chkup='/usr/lib/update-notifier/apt-check -p --human-readable' + alias chkboot='cat /var/run/reboot-required' + + alias pkgfiles='dpkg --listfiles' + alias listinstalled='aptitude search "~i!~M"' + fi +} + +_set_pkg_aliases diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index 29d1dc94..1ae200d7 100755 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -259,7 +259,7 @@ function __check_completion () { @test "completion bash-it: enable - provide the a* aliases when not enabled" { run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt atom" + assert_line -n 0 "all ag ansible apt aptitude atom" } @test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and name" { @@ -267,7 +267,7 @@ function __check_completion () { assert_link_exist "$BASH_IT/aliases/enabled/atom.aliases.bash" run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt" + assert_line -n 0 "all ag ansible apt aptitude" } @test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and priority-based name" { @@ -275,7 +275,7 @@ function __check_completion () { assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash" run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt" + assert_line -n 0 "all ag ansible apt aptitude" } @test "completion bash-it: enable - provide the a* aliases when atom is enabled with the new location and priority-based name" { @@ -283,7 +283,7 @@ function __check_completion () { assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash" run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt" + assert_line -n 0 "all ag ansible apt aptitude" } @test "completion bash-it: enable - provide the docker* plugins when docker-compose is enabled with the old location and name" {