[arch-general] manage starting and stopping processes with less typing
David C. Rankin
drankinatty at suddenlinkmail.com
Tue Apr 13 21:48:54 EDT 2010
On 04/13/2010 02:34 PM, Gaurish Sharma wrote:
> On Wednesday 14 Apr 2010 12:52:43 am David C. Rankin wrote:
>
<snip>
> I wrote a similar bash function, which I placed my ~/.bashrc. Sharing it here:
>
> start()
> {
> for arg in $*; do
> sudo /etc/rc.d/$arg start
> done
> }
<snip>
> It works as
> $ start <insert service name>
> $ restart <insert service name>
> $ status <insert service name>
>
> Hope it helps
Gaurish,
Thanks. That's cool and has given me a couple of more ideas. Here a couple more
of my favorites for .bashrc. I don't know what everyone else does for pacman
aliases, but I just use the pm<stuff> shown below:
## functions
wgnc()
{
if [[ -z $1 ]]; then
echo -e "\n Usage: wg <filename>\t\t(runs wget --no-check-certificate
--progress=bar)\n"
else
wget --no-check-certificate --progress=bar $1
fi
}
showhist() {
[[ -z $1 ]] && { echo -e "\nUsage: hist <search term>\n"; return 1; }
history | grep $1
return 0
}
mkdircd() {
[[ -z $1 ]] && { echo -e "\nUsage: mdcd <newdir>\n"; return 1; }
mkdir -p $1 && cd $1 || { echo -e "\n Failed to make or change to directory:
$1\n"; return 1; }
return 0
}
perledinln() {
if [[ ! -f $2 ]]; then
echo -e "\n Usage ${0##*/} REGEX filename\n\n Will edit the file
in-place based on REGEX using perl\n"
else
REGEX=$1
INFILE=$2
perl -p -i -e $REGEX $INFILE
fi
}
fnkwrite() { [[ -f $1 ]] && ( /opt/kde/bin/kwrite $1 & ) || (
/opt/kde/bin/kwrite & ); }
fnkate() { [[ -f $1 ]] && ( /opt/kde/bin/kate $1 & ) || ( /opt/kde/bin/kate & ); }
## aliases
alias hist='showhist'
alias mdcd='mkdircd'
alias ppie='perledinln'
alias wg='wgnc'
alias kw='fnkwrite'
alias ka='fnkate'
#
## pacman aliases (of course just remove sudo for root .bashrc)
#
alias pm='sudo pacman'
alias pmq='sudo pacman -Q'
alias pmql='sudo pacman -Ql'
alias pmqi='sudo pacman -Qi'
alias pmr='sudo pacman -R'
alias pms='sudo pacman -Sy --needed'
alias pmss='sudo pacman -Ss'
alias pmu='sudo pacman -U'
alias pmsu='sudo pacman --sync --refresh --sysupgrade'
--
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com
More information about the arch-general
mailing list