Using an editor of your choosing open your .bashrc or .bash_profile and add the following lines:
# User defined functionsNote: In the above I have aliased `ll` as -> alias ll='ls -ASlh'
function cdl { cd $1 && echo $PWD && ll; }
Note: You can name this whatever you choose, I just think `cdl` made sense.
Note: You can omit the echo $PWD if you don't care to see the directory path in the output. So you could do something as simple as:
# User defined functionsSave and close and then
function cdl { cd $1 && ls; }
bkarels@rev0:~$ source ~/.bashrcNow you can use cdl (or whatever you've named it to change directory and immediately ls the contents.
Example:
bkarels@rev0:~$ cdl foo/
/home/bkarels/fooThe above example was done on Debian 7 (Wheezy) but should work on all flavors of *nix and OSX.
total 328K
-rw------- 1 bkarels bkarels 156K Aug 8 09:39 sample0
-rw------- 1 bkarels bkarels 6.9K Aug 8 08:47 someFile27
-rw-r--r-- 1 bkarels bkarels 4.1K Aug 7 12:07 sayWhat
drwx------ 6 bkarels bkarels 4.0K Aug 8 07:37 killWindows.exe
FIN
No comments:
Post a Comment