Professional Web Applications Themes

modify shell command behavior in bash? - Linux Setup, Configuration & Administration

this initially seemed simple, but i find no success so far. i want to modify behavior of the shell command 'CD', so that every time it's executed i move to the target directory and list all files there. so far, i have this: alias la='ls -aF' alias cd='cd $1;la' that just leaves me at the starting level but returns the content of the target directory. other combinations of space and quotes don't return what i want. what am i missing here?...

  1. #1

    Default modify shell command behavior in bash?

    this initially seemed simple, but i find no success so far.

    i want to modify behavior of the shell command 'CD', so that every time it's
    executed i move to the target directory and list all files there. so far, i
    have this:

    alias la='ls -aF'
    alias cd='cd $1;la'

    that just leaves me at the starting level but returns the content of
    the target directory. other combinations of space and quotes don't return
    what i want. what am i missing here?

    jmw Guest

  2. #2

    Default Re: modify shell command behavior in bash?

    On Sun, 11 Jan 2004 21:53:28 GMT, jmw wrote: 

    try a function, example:

    function cdl
    { cd $
    ls -aF
    }

    cdl /tmp
    pwd
    Bit Guest

  3. #3

    Default Re: modify shell command behavior in bash?

    Bit Twister wrote:
     
    [...] 
    >
    > try a function, example:
    >
    > function cdl
    > { cd $
    > ls -aF
    > }
    >
    > cdl /tmp
    > pwd[/ref]

    a-HA! ...it -is- simple. thanks.

    jmw Guest

  4. #4

    Default Re: modify shell command behavior in bash?

    jmw <thanks> wrote: 
     
     
     

    A command that is run each time you change directory. In tcsh, there is
    a variable which defines that.

    In bash, you will have to simulate that.

    I presume a function rather than an alias would be more sensible.

    cd() { builtin cd $1; ls -aF; }


    Peter
    P.T. Guest

  5. #5

    Default Re: modify shell command behavior in bash?

    On Sun, 11 Jan 2004 21:53:28 GMT, jmw <thanks> wrote: 

    I use this bash function:

    cs () {

    cd "$1" && ls -Fa

    }


    Very useful.


    AC

    Alan Guest

Similar Threads

  1. Newbie! How to learn Bash shell online ?
    By Charles in forum Linux Setup, Configuration & Administration
    Replies: 8
    Last Post: December 6th, 03:09 PM
  2. Replies: 4
    Last Post: November 28th, 05:28 PM
  3. Want to change shell to bash for only one file
    By Scott in forum PHP Development
    Replies: 1
    Last Post: September 7th, 03:04 PM
  4. [PHP] Want to change shell to bash for only one file
    By Evan Nemerson in forum PHP Development
    Replies: 0
    Last Post: September 7th, 08:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139