Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
quick access to rc-scripts
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
kromo
n00b
n00b


Joined: 01 Aug 2003
Posts: 8

PostPosted: Mon Oct 06, 2003 12:00 am    Post subject: quick access to rc-scripts Reply with quote

Being annoyed of pressing tab twice for /etc/init.d/ I wrote two little scripts:

/usr/local/bin/service:
Code:
#!/bin/sh

if [ -f "/etc/init.d/$1" ]; then
     /etc/init.d/$1 $2
else
    echo -e "Unknown service: $1\n"
fi


/etc/bash_completion.d/services:
Code:
# services completion by kromo <gentoo@kromo.de>

_service()
{
        local cur services

        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}

        # get available services
        services=`ls /etc/init.d/`

        if [ $COMP_CWORD -eq 1 ]; then
                COMPREPLY=( $( compgen -W "$services" -- $cur ) )
        elif [ $COMP_CWORD -eq 2 ]; then
                COMPREPLY=( $( compgen -W "start stop restart pause zap status \
                                 ineed iuse needsme usesme broken" -- $cur ) )
        fi

        return 0

}

complete -F _service service


Hopefully someone has a use for this.
Suggestions are welcome.
Back to top
View user's profile Send private message
markfl
Apprentice
Apprentice


Joined: 10 Apr 2003
Posts: 240
Location: Kent, UK

PostPosted: Tue Oct 07, 2003 9:40 am    Post subject: Reply with quote

ln -s /etc/init.d/ /rc-scripts?
might work
_________________
Life it seems, will fade away
Drifting further every day
Back to top
View user's profile Send private message
nianderson
Guru
Guru


Joined: 06 May 2003
Posts: 369
Location: Lawrence, KS

PostPosted: Tue Apr 25, 2006 1:12 pm    Post subject: Re: quick access to rc-scripts Reply with quote

This seems pretty cool but can you explain how this completion script loads?

/etc/bash_completion.d/services:
Code:
# services completion by kromo <gentoo@kromo.de>

_service()
{
        local cur services

        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}

        # get available services
        services=`ls /etc/init.d/`

        if [ $COMP_CWORD -eq 1 ]; then
                COMPREPLY=( $( compgen -W "$services" -- $cur ) )
        elif [ $COMP_CWORD -eq 2 ]; then
                COMPREPLY=( $( compgen -W "start stop restart pause zap status \
                                 ineed iuse needsme usesme broken" -- $cur ) )
        fi

        return 0

}

complete -F _service service
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum