commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
# AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages
# (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies
# and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]).
# aliases (copy into ~/.bashrc file):
a r='ap autoremove -y'
a up='ap update'
a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean'
# && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed".
I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names.
# To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs
# For more useful aliases go to ow.ly/zBMOx
Search, find and list aliases that match a regexp.
# basic search example:
# loose search example:
# remember to double escape special characters; example:
Simply sourcing .bashrc does not function correctly when you edit it and change an alias for a function or the other way round with the *same name*.
I therefor use this function. Prior to re-sourcing .bashrc it unsets all aliases and functions.
You may want to just use the shortcut "." instead of "source"
Any changes to BASH shell made in .bashrc will be active in the current terminal window from the moment you execute this command, ie. aliases, prompt settings etc. No need to restart terminal.
(In BASH 'source' simile to 'eval' lets you generally execute any bunch of commands stacked in a text file).
When setting up a new aliases file, or having creating a new file.. About every time after editing an aliases file, I source it. This alias makes editing alias a bit easier and they are useful right away. Note if the source failed, it will not echo "aliases sourced".
Sub in vi for your favorite editor, or alter for ksh, sh, etc.
In Bash, when defining an alias, one usually loses the completion related to the function used in that alias (that completion is usually defined in /etc/bash_completion using the complete builtin).
It's easy to reuse the work done for that completion in order to have smart completion for our alias.
That's what is done by this command line (that's only an example but it may be very easy to reuse).
Note 1 : You can use given command line in a loop "for old in apt-get apt-cache" if you want to define aliases like that for many commands.
Note 2 : You can put the output of the command directly in your .bashrc file (after the ". /etc/bash_completion") to always have the alias and its completion
The example command deletes all aliases for network interface 'em0' assuming that the aliases have netmask of 255.255.255.255 and the master IP has some other netmask (such as 255.255.255.0). See here -> http://my.galagzee.com/2009/07/22/deleting-all-network-interface-aliases/ for more on the rationale of this command.