You are not logged in.

Announcement

Due to heavy spamming of forums registration is going in stages. If you wish to register as a new user with ArchBang Forums, first register and then send an e-mail to: archbangforums at gmail dot com. It should contain the problem you want to discuss or some other AB related content. You will be promoted from registering member with no posting rights to new member with posting rights after that. If your mail is ignored you haven't fulfilled the requirements.

#1 2012-07-01 05:24:13

Mr Green
Iso Developer
Registered: 2010-11-07
Posts: 3,749

acf a script to search and edit config files

Something some may find useful is a way of opening config files in an editor by using just their name

#!/usr/bin/env bash
# acf by Mr Green

term="sudo lxterminal -e <editor> "
search=$1

# Message if no file name given
function usage()
{
echo $"Usage: $0 <file/config_name>"
echo $"or use pacnew or pacsave to find"
echo  "pacman installed files"
}

# Check for pacnew or pacsave in search
case $search in
  pacnew) search='*.pacnew' 
  ;;
  pacsave) search='*.pacsave'
  ;;
  conf) search='*.conf'
  ;; 
  *) [ -z $search ] && usage && exit 1
  ;;
esac

# Search for file in /etc and users home directory
find /etc $HOME -name "${search}" -type f 2>/dev/null -exec ${term} '{}' \;

Just change <editor> to your chosen editor

Use

acf <file name>
acf pacnew

acf will search for all pacnew files in /etc

acf pacman.conf

Will load up /etc/pacman.conf in your editor

If acf finds more than one config/file with the same name it will open them all

Questions or suggestion welcome

Offline

Board footer

Powered by FluxBB