Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 433  / 1 Year ago, tue, april 11, 2023, 1:53:34

In Ubuntu 11.04 or 10.04, how can I make the apt-get, apt-cache all in one myapt so that I can simply use one only, like in Fedora?



For example:



myapt search yum   # same as apt-cache search
myapt remove yum # same as apt-get remove
myapt install yum # same as apt-get install


Any idea how to do alias for this?


More From » 11.04

 Answers
3

You could create a script with the following content



#!/bin/bash

command="$1"; shift

case $command in
add|depends|dotty|dump|dumpavail|gencaches|madison|pkgnames|policy|rdepends|search|show|showpkg|showsrc|stats|unmet|xvcg)
apt-cache "$command" "$@"
;;
autoclean|autoremove|build-dep|check|clean|dist-upgrade|dselect-upgrade|install|purge|remove|source|update|upgrade)
apt-get "$command" "$@"
;;
esac


Suppose you call it myapt. Then, to still having the benefit of bash completion, you need to add the following lines to ~/.bashrc:



_myapt() {
_apt_get
tt=("${COMPREPLY[@]}")
_apt_cache
COMPREPLY+=("${tt[@]}")
return 0
} &&
complete -F _myapt $filenames myapt


Unfortunately $command should precede any options, but seems that bash completion do not works for options that follow command.


[#43374] Tuesday, April 11, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ibuteking

Total Points: 35
Total Questions: 128
Total Answers: 138

Location: Indonesia
Member since Thu, Oct 1, 2020
4 Years ago
ibuteking questions
Sat, Sep 10, 22, 08:44, 2 Years ago
Fri, May 12, 23, 10:10, 1 Year ago
Tue, May 23, 23, 13:38, 1 Year ago
;