LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-06-2005, 08:19 PM   #1
whatnoname
LQ Newbie
 
Registered: Jun 2005
Posts: 7

Rep: Reputation: 0
adding an option to a 'tab' completion + ls


Hi all,

I wasn't too sure how to name the thread.. but...

I have
Code:
alias ls='ls -lh --color'
set in my /etc/bashrc file. Gives a nice output. But say I want to ls the contents of a folder I'm not sure of the exact name.. So for example you'd do " ls /usr/local <tab> <tab> ", but this gives the output in the bog standard short-ls way, and not my ls -lh --color way I prefer.

So what / where do I have to edit to get this altered <tab> output thingy

I's also like to change the ls format too, to show the total size of a directory.
Code:
drwx------  11 meep        users   4.0K Jun  7 01:19 meep
drwxr-xr-x   3 root        root    4.0K Dec  2  2004 www
So instead of it showing the '4.0K' it lists the actual size of the meep- or www folders inc. subdirs.

Thanks to you if you can set me straight!

 
Old 06-06-2005, 09:22 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
for the alias ls command you set i dont think you can have it work with the '<tab> thingy'. when u press tab like that it is a feature of the shell. it is for auto completion. when it finds only one result it will display that one, when it finds more than one it will display them all as a convenience to you to let you know which one you need to work with, or whatever. so, again, i dont think you can achieve what your saying.. someone correct me if im wrong, though.

for the directory size, the ls command is doing what it is supposed to.. its showing you the size of the file. however, in the case you mentioned, those files are 'directories' and they are handled the same way as any other file with ls. it IS showing you the size of it, but not the size of its contents and their contents (recursively). you would i think either need to write a script, or you can use the 'du' (disk usage) command. see the man page here
ex:
Code:
du /home/nadroj/mp3s
edit: i dont have access to *nix right now and i might be wrong here.. if its not du then the command is df, i havent used them in while and forget. it wont kill you if you accidently do either, of course.

Last edited by nadroj; 06-06-2005 at 09:27 PM.
 
Old 06-07-2005, 07:32 AM   #3
whatnoname
LQ Newbie
 
Registered: Jun 2005
Posts: 7

Original Poster
Rep: Reputation: 0
Shame on both counts really - You get used to the long format for the ls command, and when you tab tab, and it's shown in the usual short ls manner, it's just bugging.
The command is du -sh say for the directory sizes, it would be nice (imho!) To have the size of directories shown in an ls command too, you could see all direcrotory sizes in one go then.

Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
enabling command option completion s_deepblue Debian 4 12-02-2005 05:42 PM
tab completion with scp fsbooks Linux - General 5 04-07-2005 03:13 PM
How can I turn on/install tab completion which I am so used to. jimdaworm *BSD 2 04-06-2005 11:25 PM
does vim have an option for code completion? sneak Linux - Software 4 07-20-2004 07:05 AM
apt-get tab completion atheist Debian 6 06-11-2004 08:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration