FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Kubuntu User

 
 
LinkBack Thread Tools
 
Old 01-24-2009, 02:36 PM
Nils Kassube
 
Default Shell tab-completion and other helpful command-line tricks

Derek Broughton wrote:
> Jonas Norlander wrote:
> > 2009/1/24 Nils Kassube <kassube@gmx.net>:
> >> Donn wrote:
> >>> On Saturday, 24 January 2009 10:12:41 Nils Kassube wrote:
> >>> > 2. The command completion doesn't work within quotes. Using the
> >>> > file name above it wouldn't work if I type this:
> >>> >
> >>> > ls "is<tab>
> >>> >
> >>> > So if you want to use command completion, don't use quotes.
> >>>
> >>> Works fine for me....
> >>
> >> Oops, now it works here as well. I must have mistyped it when I
> >> tried it earlier this morning, maybe it was a lack of coffee?
> >> Anyway, sorry - and scratch that part.
> >
> > That on the other hand don't work for me, neither in Konsole or on a
> > "pure" console.
>
> Nor me - and I really wouldn't have expected it to. Since bash
> explicitly prevents expansion of anything inside double quotes, it
> seems perfectly normal that bash completion can't work.

Meanwhile I have tested it with the LiveCD of both 8.04 and 8.10. With
8.04 my example above (ls "is<tab>) works but not with 8.10. Possibly
that is the reason why my first test this morning didn't work but the
second test did work.


Nils

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-24-2009, 04:07 PM
Paul Rumelhart
 
Default Shell tab-completion and other helpful command-line tricks

Derek Broughton wrote:
> Nils Kassube wrote:
>
>
> bash completion is fairly arcane to me, but aiui it's up to the command's
> packager to add some relevant file with the completions. Everybody should
> have apt-get - so you can try "apt-get -<tab>". Unfortunately, apt-get's
> completions are part of the default system, so the "apt" package doesn't
> have a special file in it.
>
>

I didn't know there were tab completion files involved. That's good to
know.

> The coolest discovery I ever made about bash completion was the fact that:
>
>
>> scp filename somehost::<tab>
>>
>
> works! It's pretty slow for the host where I usually want to use it, but so
> handy.
>

I've also found it works in some other programs that take input from the
command-line, such as psql (an interface into Postgresql). I assume
that's built in to the psql code, and doesn't have anything to do with
the bash shell.

Take a look at the file /etc/bash_completion to get an idea of how many
commands support tab completion. I've been reading up on this, since
you've gotten me curious. Bash has facilities for adding custom tab
completion to scripts you write yourself, in case you need your script
to look at usernames or environment variables or whatever when you press
<tab>. Pretty cool stuff.

There is a command called "compgen" that you can call that tells you
what will be matched for whichever program. For example, if you want to
find out what tab completion will find for users on your system that
start with the letter "r", type: "compgen -A user -- r" and it should
give you the same list that "user r<tab>" does. This could be helpful
inside scripts for various user inputs. There is also a command called
"complete" that you can use to assign tab completion to your program,
but I haven't tried that one. I'll have to play around with some scripts.

Paul

Paul


--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-24-2009, 04:37 PM
Derek Broughton
 
Default Shell tab-completion and other helpful command-line tricks

Paul Rumelhart wrote:

> Derek Broughton wrote:
>> Nils Kassube wrote:
>>
>>
>> bash completion is fairly arcane to me, but aiui it's up to the
>> command's
>> packager to add some relevant file with the completions. Everybody
>> should
>> have apt-get - so you can try "apt-get -<tab>". Unfortunately, apt-get's
>> completions are part of the default system, so the "apt" package doesn't
>> have a special file in it.
>>
>>
>
> I didn't know there were tab completion files involved. That's good to
> know.

/etc/bash_completion.d/

> I've also found it works in some other programs that take input from the
> command-line, such as psql (an interface into Postgresql). I assume
> that's built in to the psql code, and doesn't have anything to do with
> the bash shell.

Nope, it's built into readline - which is part of bash (if I'm not
completely confused!). In any case, it's possible to get completions from
most such programs (and yes, I use it in psql all the time).

> There is a command called "compgen" that you can call that tells you
> what will be matched for whichever program. For example, if you want to
> find out what tab completion will find for users on your system that
> start with the letter "r", type: "compgen -A user -- r" and it should
> give you the same list that "user r<tab>" does. This could be helpful
> inside scripts for various user inputs. There is also a command called
> "complete" that you can use to assign tab completion to your program,
> but I haven't tried that one. I'll have to play around with some scripts.

Neat - I didn't know about those.



--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-29-2009, 08:09 PM
Jonas Norlander
 
Default Shell tab-completion and other helpful command-line tricks

2009/1/23 Paul Rumelhart <godshatter@yahoo.com>:
>
> I hope you find this helpful, and if you know of any cute tab-completion
> tricks please let us know. If you use the command-line a lot, you'll
> find that pressing the tab key becomes instinctive and you'll really
> miss it when you are in a program that doesn't use it.
>
> Paul
>

One thing i use all the time with bash is the command history and the
readline shortcuts. So here is some of my most used shortcuts.
Arrow up or CTRL+P will fetch the previous command from the history.
Arrow down or CTRL+N will fetch the next command from the history.
CTRL+R will reverse search history for what ever you enter. Greate for
fetching that complicated command you wrote some days ago but dont
remember.
CTRL+A move to beginning of line.
CTRL+E move to end of line.
ALT+F move forward a word.
ALT+B move back a word.
CTRL+L clear screen.
CTRL+k remove the text from the cursor to the end of the line.
CTRL+X BACKSPACE remove text from the cursor to the beginning of the line.
ALT+D delete a word forward.
ALT+BACKSPACE delete a word backwards.

And there is more shortcuts in the readline library like copy and
paste that could help a lot when working in the shell.

/ Jonas

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-29-2009, 10:59 PM
Derek Broughton
 
Default Shell tab-completion and other helpful command-line tricks

Jonas Norlander wrote:

> CTRL+A move to beginning of line.

I'd completely forgotten that I used to do that, because HOME usually does
the job, now
> CTRL+E move to end of line.

END

> ALT+F move forward a word.

CTRL-RIGHT (except I buggered that by following somebody else's advice, and
haven't got around to fixing it, so it's nice to see that ALT-F and ALT-B
still work)

> ALT+B move back a word.

CTRL-LEFT

> CTRL+L clear screen.
> CTRL+k remove the text from the cursor to the end of the line.

hmmm. Never did know that one...

> CTRL+X BACKSPACE remove text from the cursor to the beginning of the line.

ctrl-U

> ALT+D delete a word forward.
> ALT+BACKSPACE delete a word backwards.

Ctrl-W

As, always with Linux, there's more than one way to do anything :-)



--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-30-2009, 12:53 AM
Steven Vollom
 
Default Shell tab-completion and other helpful command-line tricks

On Thursday 29 January 2009 4:09:03 pm Jonas Norlander wrote:
> 2009/1/23 Paul Rumelhart <godshatter@yahoo.com>:
> > I hope you find this helpful, and if you know of any cute tab-completion
> > tricks please let us know. If you use the command-line a lot, you'll
> > find that pressing the tab key becomes instinctive and you'll really
> > miss it when you are in a program that doesn't use it.
> >
> > Paul
>
> One thing i use all the time with bash is the command history and the
> readline shortcuts. So here is some of my most used shortcuts.
> Arrow up or CTRL+P will fetch the previous command from the history.
> Arrow down or CTRL+N will fetch the next command from the history.
> CTRL+R will reverse search history for what ever you enter. Greate for
> fetching that complicated command you wrote some days ago but dont
> remember.
> CTRL+A move to beginning of line.
> CTRL+E move to end of line.
> ALT+F move forward a word.
> ALT+B move back a word.
> CTRL+L clear screen.
> CTRL+k remove the text from the cursor to the end of the line.
> CTRL+X BACKSPACE remove text from the cursor to the beginning of the line.
> ALT+D delete a word forward.
> ALT+BACKSPACE delete a word backwards.
>
> And there is more shortcuts in the readline library like copy and
> paste that could help a lot when working in the shell.
>
> / Jonas

This wasn't directed to me, however, thanks. I have saved it. Now I just
have to memorize and use it.

Steven



--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-30-2009, 05:30 AM
Paul Rumelhart
 
Default Shell tab-completion and other helpful command-line tricks

Jonas Norlander wrote:
> 2009/1/23 Paul Rumelhart <godshatter@yahoo.com>:
>
>> I hope you find this helpful, and if you know of any cute tab-completion
>> tricks please let us know. If you use the command-line a lot, you'll
>> find that pressing the tab key becomes instinctive and you'll really
>> miss it when you are in a program that doesn't use it.
>>
>> Paul
>>
>>
>
> One thing i use all the time with bash is the command history and the
> readline shortcuts. So here is some of my most used shortcuts.
> Arrow up or CTRL+P will fetch the previous command from the history.
> Arrow down or CTRL+N will fetch the next command from the history.
> CTRL+R will reverse search history for what ever you enter. Greate for
> fetching that complicated command you wrote some days ago but dont
> remember.
> CTRL+A move to beginning of line.
> CTRL+E move to end of line.
> ALT+F move forward a word.
> ALT+B move back a word.
> CTRL+L clear screen.
> CTRL+k remove the text from the cursor to the end of the line.
> CTRL+X BACKSPACE remove text from the cursor to the beginning of the line.
> ALT+D delete a word forward.
> ALT+BACKSPACE delete a word backwards.
>
> And there is more shortcuts in the readline library like copy and
> paste that could help a lot when working in the shell.
>
> / Jonas
>
>

I didn't know about most of those. I'd used arrow up and down before,
but not the others. Thank you.

Paul


--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-30-2009, 08:55 AM
Jonas Norlander
 
Default Shell tab-completion and other helpful command-line tricks

2009/1/30 Derek Broughton <derek@pointerstop.ca>:
> Jonas Norlander wrote:
>
>> CTRL+A move to beginning of line.
>
> I'd completely forgotten that I used to do that, because HOME usually does
> the job, now
>> CTRL+E move to end of line.
>
> END
>
>> ALT+F move forward a word.
>
> CTRL-RIGHT (except I buggered that by following somebody else's advice, and
> haven't got around to fixing it, so it's nice to see that ALT-F and ALT-B
> still work)
>
>> ALT+B move back a word.
>
> CTRL-LEFT
>
>> CTRL+L clear screen.
>> CTRL+k remove the text from the cursor to the end of the line.
>
> hmmm. Never did know that one...
>
>> CTRL+X BACKSPACE remove text from the cursor to the beginning of the line.
>
> ctrl-U
>
>> ALT+D delete a word forward.
>> ALT+BACKSPACE delete a word backwards.
>
> Ctrl-W
>
> As, always with Linux, there's more than one way to do anything :-)
>

I think it's something difference with ctrl-u and ctrl-w and checking
the manual gives that the deleted text is saved to the "kill-ring".
Copied from the manual:

backward-kill-line (C-x Rubout)
Kill backward to the beginning of the line.
unix-line-discard (C-u)
Kill backward from point to the beginning of the line.
The killed text is saved on the kill-ring.
backward-kill-word (M-Rubout)
Kill the word behind point. Word boundaries are the
same as those used by backward-word.
unix-word-rubout (C-w)
Kill the word behind point, using white space as a word
boundary. The killed text is saved on the kill-ring.

Could be useful if one learn how to use it. Sometimes i think there is
to many ways to do one thing in Linux but on the other hand thats
probably what make its so fascinating.

/ Jonas

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 
Old 01-30-2009, 09:07 AM
P Kapat
 
Default Shell tab-completion and other helpful command-line tricks

CTRL +_ (undo == life saver) of simply CTRL+c

An interesting place: http://www.shell-fu.org/
--
Regards
PK
--------------------------------------
http://counter.li.org #402424

--
kubuntu-users mailing list
kubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/kubuntu-users
 

Thread Tools




All times are GMT. The time now is 06:59 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org