Use autocomplete in simple bash command/aliases

I have a really cheesy alias basically to use to cd into directory in public_html
cdw() {
cd ~/public_html/$*
how do I get that to use autocomplete with it?
Thanks

you'll have to write a completion file under /etc/bash_completion.d/.  you can take a look at some of the ones in there for examples (try to find a simple one). 
you basically have to build a list of what to complete (probably ~/public_html/* in your case), then hand that off to a completion function, source the file and try it.

Similar Messages

  • How to write a simple bash command

    I have a mac mini that has some software that is supposed to start at bootup, but does not always do so.  In order to get the software running I need to open a terminal window and type some commands.  Is it possible to just write a text file and turn it into a .command file that will not require me to write it out every time.
    Here is exactly what I have to write in Terminal to get the program running again.
    sudo su
    filler14
    ignition stop
    ignition start
    exit
    exit
    Typing sudo su asks for the password which is filler14.  After entering it I type ignition stop and it takes a second and it responds that it stopped.  I type ignition start and it takes about 3 seconds and responds that it is running.  I type exit to get out of sudo su and then exit again and it says operation complete, and then I close terminal.
    Is there a way to automate this?
    Thanks,
    Michael

    You need to create a launchd plist for it and put it in the /Library/LaunchDaemons folder. It will run as root on startup.
    There are several tutorials all over the web, or you can use Lingon X ($10 probably is too steep for what you want--and likely isn't needed). The App Store version is cheaper, but cannot save directly to the /Library/LaunchDaemons folder due to App Store limitations. However, Peter Borg (developer) notes that you can just create one for your user, then move it to the Library/LaunchDaemons folder yourself.

  • How to use simple input command ??

    I am tired of trying to find an easy to understand source to implement simple INPUT command ( equivalent to cin>> and scanf() , in c++ and c as i m good in those two)
    when print can be System.out.println(--) , then y does read have to be so complicated ?
    Help me out guys !!!

    package palindrome;
    import java.io.DataInputStream;
    * @author Pulkit
    class Main {
    public static void main(String[] args) {
    int num;
    System.out.println("Enter a number to check if it is palindrome");
    // System.in.readline(num);
    DataInputStream ob = new DataInputStream(System.in);
    Now the remark line is wat i tried to do, as i thought it should follow the print method ( System.out.print ) that one.
    But in a book , i see its done just the other way, just below the rem line.
    I just need ur help to explain me as to how that line has been put, i.e. the syntax of that line.

  • Accessing Bash Command on Lion OS X.

    Hello Apple Forum Community.  Can anyone help me to understand how you access Bash in Lion (through which Utilities)?  If you are not a professional programmer or developer, is Bash command still worthy of being educated about on your Mac?  A website was describing a Bash command prompt for UNIX passwords; hence, could using Bash to generate and/or organize your passwords be your best bet?  Should we really trust 'random password generator' websites to create UNIX passwords, or are we simply wasting our time if we are really not creating the proper password for our Lion OS X. 
    What other functions can Bash be useful for?  Are there a few simple ways to know and/or get into Bash (to know a few advantageous command prompts) for the general Mac user.  Are any Bash commands different for OS X Lion, or are there new ones as well? Thanks.

    Open Applications->Utilities->Terminal.
    I believe the default shell for at least the last few releases is bash, so you'll get straight to it (though I have mine set to tcsh). If not, just type /bin/bash to start a bash shell.
    Random password generator sites are fine  - all they do is generate a random sequence of characters. However, you're probably going to have to write that password down to remember it, which makes it less secure. Better to come up with a sequence that has some mnemonic meaning to you, that contains uppercase and lowercase letters, numbers and other characters, and is at least eight characters long.
    I doubt there's any need for the "general Mac user" to be using a shell, but if you are interested in programming or getting to know how the OS works "under the hood", then it's worth learning about. There are any number of good resources on the web about UNIX shells.

  • Simple bash scripting help needed..

    I want to learn som simple bash scripting in order to automate various tasks.. Im totally noob, so bear with me
    First of all I would like to set configs without using nano.. is there a simple command for this? For example if i want change my hostname in /etc/rc.conf.. how can i print the current vallue and how can i change it`?
    i was thinking something like this to get the current value:
    # cat /etc/rc.conf | grep HOSTNAME=
    which returns HOSTNAME="myhostname"
    how can i change this value with one or more commands whitout touching the rest of the file?

    abesto wrote:
    A slightly naive solution:
    CHOICE="lisa"
    NAMES="homer marge lisa bart maggie"
    if [ "`echo \" $NAMES \" | grep \" $CHOICE \"`" ]; then
    echo "this is how you do it"
    fi
    The extra spaces inside the escaped quotes are to ensure that only a whole word is "matched".
    You can also replace the elif's with a loop through a list of "the other variables". Then you'd use the loop variable instead of $CHOICE above.
    grep can check on word-bounderies with \< and \>, or with the -w switch. The -q switch suppresses any messages and exits with exit-code 0 when the first match is found:
    if echo "${NAMES}" | grep -qw "${CHOICE}"; then
    Nice and readable, should work, but i haven't tested it
    EDIT:
    Procyon wrote:CHOICE="lisa"
    NAMES="homer marge lisa bart maggie"
    if [[ $NAMES =~ $CHOICE ]]; then echo match; fi
    This one also matches elisa, ie. no check on word bounderies. You should be carefull with that
    Last edited by klixon (2009-04-23 09:40:22)

  • Simple Java Command-Line on Unix Question

    From the windows shell, the following command works fine:
    java -classpath MyJar.jar;. Test
    The class Test, in the current director, depends on files in MyJar.jar. However, when I open up the cygwin bash shell and try to execute the same command, I get this error:
    bash: /usr/bin/Test: No such file or directory
    It appears it's looking for Test in /usr/bin as opposed to in the current directory. Why is this happening and how can I get this to work in bash?
    I know it's kind of unix question, but I figured some one here could help.
    TIA,
    John

    How can I use aboslute classpaths within bash. For
    example, what it the bash equivalent of the
    following:
    java -classpath C:/Java;C:/Java/MyJar.jar Testjava -classpath /the/path/to/your/Java:/the/path/to/your/MyJar.jar Test
    Normally you will be using things relative to your home directory so yo can use
    java -classpath ~ /the/relative-path/to/your/Java:~/the/relarive-path/to/your/MyJar.jar Test
    or
    java -classpath $HOME/the/relative-path/to/your/Java:$HOME/the/relative-path/to/your/MyJar.jar Test
    Please don't use these blindly. Spend some time (half a day say) looking at the bash shell!

  • Bash commands not working after upgrade to Lion

    After upgrade, many BASH commands not working. For example, such a fundamental thing as "ls". 
    iMac20:bin a$ ls
    Launch of "ls" failed: the PowerPC architecture is no longer supported.
    What does it have to do with PowerPC? My computer is 2.66 GHz Inter Core Duo

    Linc,
    iMac20:~ a$ which ls
    /sw/bin/ls
    Also, I managed to look (using tcsh's ls-F command) into the contents of /usr/. Here's what I see there:
    [iMac20:/bin] a% ls-F
    [*          csh*        echo*       ksh*        mkdir*      rcp*        stty*       wait4path*
    bash*       date*       ed*         launchctl*  mv*         rm*         sync*       zsh*
    cat*        dd*         expr*       link*       pax*        rmdir*      tcsh*      
    chmod*      df*         hostname*   ln*         ps*         sh*         test*      
    cp*         domainname* kill*       ls*         pwd*        sleep*      unlink*    

  • BASH Command.

    How can i use BASH commands to get files Added on a certain month?
    (I can use only date,ls,cut,awk,sed).
    please help if anybody know...

    (I can use only date,ls,cut,awk,sed).
    Pretty restrictive bash script  If that's the only commands you can use.  What's putting on these restrictions?
    Does it have to be a bash script?  Or are you just want something to produce those results?  Because the system's find (command+f) or utilities like Find any File can do this.  Just look for a mod date within a range.
    For bash do a google search for something like "os x bash to get mod date" for script suggestions.

  • Simple BASH script to update subversion files

    This is just a simple BASH script that will update all .svn files in a specified directory.  If an update fails, it will attempt to update all the subdirectories in the failed one, so as much will be updated as possible.  Theoretically, you should be able to supply this script with only your root directory ( / ), and all the .svn files on your computer will be updated.
    #! /bin/bash
    # Contributor: Dylon Edwards <[email protected]>
    # ================================
    # svnup: Updates subversion files.
    # ================================
    #  If the user supplies no arguments
    #+ then, update the current directory
    #+ else, update each of those specified
    [[ $# == 0 ]] \
        && dirs=($PWD) \
        || dirs=($@)
    # Update the target directories
    for target in ${dirs[@]}; do
        # If the target file contains a .svn file
        if [[ -d $target/.svn ]]; then
            # Update the target
            svn up $target || {
                # If the update fails, update each of its subdirectories
                for subdir in $( ls $target ); do
                    [[ -d $target/$subdir ]] &&
                        ( svnup $target/$subdir )
                done
        # If the target file doesn't contain a .svn file
        else
            # Update each of its subdirectories
            for subdir in $( ls $target ); do
                [[ -d $target/$subdir ]] &&
                    ( svnup $target/$subdir )
            done;
        fi
    done

    Cerebral wrote:
    To filter out blank lines, you could just modify the awk command:
    ${exec awk '!/^$/ { print "-", $_ }' stuffigottado.txt}
    very nice; awk and grep: two commands that never cease to amaze me.

  • Simple bash menu

    I wanted a simple bash menu where arrow keys could be used to select items. So here it is. It requires cuu and cud in the teminfo or it fails to look nice.
    Example usage, distro="`smenu ArchLinux Debian Ubuntu Gentoo`"
    Feel free to modify and adapt for your own personal usage.
    #!/bin/bash
    # input: list of menu items
    # output: item selected
    # exit codes: 0 - normal, 1 - abort, 2 - no menu items, 3 - too many items
    # to select item, press enter; to abort press q
    [[ $# -lt 1 ]] && exit 2 # no menu items, at least 1 required
    [[ $# -gt $(( `tput lines` - 1 )) ]] && exit 3 # more items than rows
    # set colors
    cn="`echo -e '\r\e[0;1m'`" # normal
    cr="`echo -e '\r\e[1;7m'`" # reverse
    # keys
    au="`echo -e '\e[A'`" # arrow up
    ad="`echo -e '\e[B'`" # arrow down
    ec="`echo -e '\e'`" # escape
    nl="`echo -e '\n'`" # newline
    tn="$#" # total number of items
    { # capture stdout to stderr
    tput civis # hide cursor
    cp=1 # current position
    end=false
    while ! $end
    do
    for i in `seq 1 $tn`
    do
    echo -n "$cn"
    [[ $cp == $i ]] && echo -n "$cr"
    eval "echo \$$i"
    done
    read -sn 1 key
    [[ "$key" == "$ec" ]] &&
    read -sn 2 k2
    key="$key$k2"
    case "$key" in
    "$au")
    cp=$(( cp - 1 ))
    [[ $cp == 0 ]] && cp=$tn
    "$ad")
    cp=$(( cp + 1 ))
    [[ $cp == $(( tn + 1 )) ]] && cp=1
    "$nl")
    si=true
    end=true
    "q")
    si=false
    end=true
    esac
    tput cuu $tn
    done
    tput cud $(( tn - 1 ))
    tput cnorm # unhide cursor
    echo "$cn" # normal colors
    } >&2 # end capture
    $si && eval "echo \$$cp"
    # eof
    Last edited by fsckd (2010-09-29 21:31:17)

    livibetter wrote:
    Nice code.
    I manually added j, k, and o (~Return) into the key checking part. I could use j,k or up,down to choose, but I wonder if that possible you can re-code to make it can accept multiple keys set in $au,$ad, and $nl.
    Thanks. In the case statement you can add multiple keys, like:
    "$au"|k)
    <snip>
    "$ad"|j)
    livibetter wrote:Also, a new option to clean up the menu after user choice or leave?
    I didn't want this which is why it's not in the script. At the bottom of the script, change tput cud $(( tn - 1 )) to tput dl $tn ; tput cuu1 and it should delete the lines.
    Bug: does not work with fish shell, set distro (./smenu ArchLinux Debian Ubuntu Gentoo); I wonder how it fares with other shells and terminals.

  • Watchless - a simple Bash helper for LESS to CSS compilation

    Here is a simple Bash tool for LESS files compilation, watching your .less files using inotifywait and compiling CSS on file change.
    Supports @import-ed files. Compiled files can go in the current directory or in another directory, keeping the directory structure intact (~/Project/less/style.less to ~/Project/css/style.css for example)
    Not well tested, may be dangerous.
    AUR: https://aur.archlinux.org/packages/watchless/

    I place all my LESS files, along with all of the JavaScript files in a sub-directory called _src (for source files). The _scr folder is Cloaked so that it is not included in file transfers. The structure looks like
    _src
        js
              bootstrap
                  ..... // files go here
              fonts
                  ..... // files go here
              jquery
                  ..... // files go here
              myscripts.js // scripts of my own that I want added
              scripts.js  // contains imported JS files that are combined and minified into one production script
        less
              bootstrap
                  ..... // files go here
              fonts
                  ..... // files go here
              footer.less //
              form.less //
              header.less  // these files are for the various parts of the template and or documents
              main.less //
              nav.less //
              styles.less // contains imported LESS files that are combined and minified into one production style sheet
    I will then use PrePros to compile the JS and CSS files making for just two HTTP requests.
    Have a look at source code (lines 7 and 110) of this site.
    Incidentally, by using PrePros, not only do the LESS and JS files get compiled automatically, any saved changes are immediately visible in my browser without having to refresh each time.

  • Bash command not working

    After an update from leopard to lion my bash command clear does not work.
    If I open terminal and type clear this happens...
    Last login: Wed Jul  4 19:07:27 on ttys000
    You have new mail.
    pancake:~ machinename$ clear
    Launch of "clear" failed: the PowerPC architecture is no longer supported.
    pancake:~ machinename$
    I have tried to copy a copy of the terminal app from another functioning machine running lion, but when it runns on the upgraded machine the result is the same.
    How can I fix this?

    Sorry I better correct some of the info.
    My bash command clear does not work.
    If I open terminal and type clear this happens...
    The machine was bought with Lion preinstalled and the Migration Assistant was use to transfer everything for a user from a Leopard machine.
    Last login: Wed Jul  4 19:07:27 on ttys000
    You have new mail.
    pancake:~ username$ clear
    Launch of "clear" failed: the PowerPC architecture is no longer supported.
    pancake:~ username$
    When attempting to delete the terminal program on the system it is prevented with the message:
    “Terminal” can’t be modified or deleted because it’s required by Mac OS X.
    I then copied a terminal program from another Lion machine but it shows the same message for the command Clear on this machine, but not the machine it was copied from.
    Any ideas is greatly appreciated...

  • Proxyagent using proxy tls:simple fails to bind to DS 6.3

    If I configure the profile to use proxy simple, it works fine everything works including authentication (/etc/pam.conf and the server are using pam_ldap:tls:simple). If I try proxy tls:simple, it fails to bind to the server. Both the server and client are Solaris 10. I generated and deployed the certificates on both sides. I searched Sunsolve and the forums. Is proxy tls:simple an unworkable combination? Proxy anonymous does not seem to work either.
    Any ideas?

    This is for my internal lab network. You will have to use ldapadd to add it to the DS configuration:
    ldapclient genprofile -a profileName=tls-profile -a defaultSearchBase=dc=gallifrey,dc=net -a credentialLevel=proxy \
    -a authenticationmethod=tls:simple -a serviceAuthenticationMethod=pam_ldap:tls:simple \
    -a serviceAuthenticationMethod=passwd-cmd:tls:simple -a defaultSearchScope=one \
    -a followReferrals=FALSE -a defaultServerlist=192.168.1.6 > tls-profile.ldif
    bash-3.00# cat tls-profile.ldif
    dn: cn=tls-profile,ou=profile,dc=gallifrey,dc=net
    ObjectClass: top
    ObjectClass: DUAConfigProfile
    defaultServerList: 192.168.1.6
    defaultSearchBase: dc=gallifrey,dc=net
    authenticationMethod: tls:simple
    followReferrals: FALSE
    defaultSearchScope: one
    cn: tls-profile
    credentialLevel: proxy
    serviceAuthenticationMethod: pam_ldap:tls:simple
    serviceAuthenticationMethod: passwd-cmd:tls:simple

  • Executing a bash command from Java

    I want to execute a bash command from within a Java application on the server. I know how to do simple commands, but this command is killing me. I get nothing back when I send it.
    p = Runtime.getRuntime().exec(new String[]{"ps","-ef","","grep","evolution"});
    There is also another part where I want the results piped to awk and fetch out the pids. BUt with this not working the rest is a waste for now.
    Robbie

    evgeni00 wrote:
    Thank you for assuming the posters' stupidity.I can only see the information that you provide. You didn't say you tried the recommendations.
    I read the article and I tried the things he/she is proposing, also the error stream, guess what it outputs: nothing.Maybe you did it wrong. If you didn't do it wrong, then that program you're invoking is poorly written, because it dies in error without producing any error messages.
    And I also searched for the exitValue 138, but didn't get much further than that its some system specific value. If you know where I can find more information, I would appreciate if you let me know about it. As jschell pointed out it's probably app specific. You can search the source code and/or documentation of that program to see if they say what 138 means.
    Apart from that -- it seems that environment and run directory issues can trip this up. Try checking that stuff out. Maybe your program expects something on the executable PATH that isn't there. Or maybe you're not running it in the working directory that you think you are.

  • How do I run a snmpwalk/any bash command as a Linux/Unix command (2 state monitor) on a Isilon storage device

    Is there a way that I can run a snmpwalk / isi devices (to find the status of the disk drives in islon) / any Linux bash command using a 2 state monitor Unix/Linux shell command and target a storage device (Isilon in my case) and not target a Unix/Linux
    machine. I tried creating one and it complained saying,
    Is there a way I could run a bash command in my isilon storage and use the ouput to determine the state of the monitor? Please let me know
    Hari V

    For Unix/Linux shell command in Operation Manager to monitor 2 state, you can refer to below link
    http://contoso.se/blog/?p=2680
    http://stefanroth.net/2012/10/21/scom-2012-linux-two-state-monitor-with-script-in-script/
    http://operatingquadrant.com/2012/02/01/opsmgr-2012-unixlinux-authoring-templates-more-information-on-the-shell-command-templates/#more-746
    Please remember, if you see a post that helped you please click (Vote As Helpful" and if it answered your question, please click (Mark As Answer).

Maybe you are looking for

  • Portal Runtime Error - Access Denied

    Hi Gurus,     I have developed a simple model using two BAPIs in the VC. Once I save and deplay the model, I am getting a message 'Deployed Successfully'. But when i click on the Run <My model> link, i am not getting the Portal screen with the layout

  • WRT350N - How to read associated usb drive??

    Ok, so I've set everything up. All our laptops have a wireless internet connection and our desktop is connected via ethernet. I have a Lacie USB drive I need to connect to the network. When I go through the Linksys software setup, the drive is recogn

  • Sampled Sounds "Not Found" After Move to New MacBook Pro

    Hello All,     I moved my Logic 9.7.1 from my old MacBook Pro to my new one via Migration assistant; both are running Lion. A smooth transition in all programs with all files showing in the same folders on both. I key in both my Logic 8 and Logic 9 s

  • Exporting to Pages

    I finally figured out how to organize photos in iPhoto and edit them. When I went to my narrative in Pages, I couldn't insert a picture from iPhoto. Hope all that work was not for naught. Help! Karen

  • How to Play One Song Without Repeat?

    I am a new Ipod user, with an 80 GB video version. (I don't think it's one of the latest new models, but the second to last generation. Is that "fifth generation"?)I updated it with the latest firmware, just a few days ago. I have used other MP3 play