LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-14-2024, 03:39 AM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,997

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338

Quote:
Originally Posted by MadeInGermany View Post
My test system does not have the bash-completion package installed. The complete command shows nothing.

I think it only modifies and extends the default behavior.
And I think your bash version has a bug.
Such a bug had already occurred 13 years ago:
https://bbs.archlinux.org/viewtopic.php?id=115548
And again 11 years ago:
https://bugs.debian.org/cgi-bin/bugr...cgi?bug=698721
And again 2 years ago:
https://bugzilla.redhat.com/show_bug.cgi?id=2026883
Again, I don't think this is a bug, it's probably intentional, it's just that some people don't like it.
Let's say the current dir contains a file 'this is a file'.
Pressing "vi thi<tab>" will produce "vi this\ is\ a\ file". What should happen, if the filename contains a $ ? Do we need to protect those strange chars? I think the perfect solution would cost a lot (that means you need to wait a lot for the completion).
completion itself is not bash, but an external "plugin", which will be invoked when you want to complete your command. But it has a long story. And yes, there can be a bug in bash too.
 
1 members found this post helpful.
Old 01-14-2024, 02:24 PM   #17
disk_bearing
Member
 
Registered: Mar 2022
Posts: 37

Original Poster
Blog Entries: 2

Rep: Reputation: 2
Fascinating!

Unfortunately I am too new to quickly understand or apply or test most conceivable fixes. So most of the time I back up everything and switch to a new distro and trade any one problem for another. Wish I learned this stuff decades ago. I'll be with yous in a decade.
 
Old 01-14-2024, 03:14 PM   #18
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by disk_bearing View Post
I said vi works perfectly but now it doesn't for some reason, maybe it actually never did.

My motive is to browse frequent dirs faster. But is this even a common practice? Is there a better method?

* answer

Code:
$ cd $shortcut
$ cd ./<tab>
This was fun. Thank you for all the help MadeInGermany, and everyone.
I do not think it is a common practice. Generally, I find ctrl-r command history search good for "cd" to a recently used dir. And if there's somewhere I need to work on heavily for a while, I'll symlink in my home directory (ln -s PathToTheDirectory).

Note that tab completion with a symlink acts slightly differently from a true folder. But you get used to it quickly enough.

Managing variables to be directory paths just seems like a lot of annoying work to me. I mean ... if I make a symlink it's there forever until I delete it. It exists across all sessions, and if I change it, it's changed across all sessions.

Setting variables every session? Having multiple terminal windows with all different variables set differently if I am changing things? Ugh. That does not sound pleasant to me.
 
1 members found this post helpful.
Old 01-14-2024, 03:40 PM   #19
disk_bearing
Member
 
Registered: Mar 2022
Posts: 37

Original Poster
Blog Entries: 2

Rep: Reputation: 2
Quote:
Originally Posted by IsaacKuo View Post
I do not think it is a common practice. Generally, I find ctrl-r command history search good for "cd" to a recently used dir. And if there's somewhere I need to work on heavily for a while, I'll symlink in my home directory (ln -s PathToTheDirectory). Setting variables every session? Having multiple terminal windows with all different variables set differently if I am changing things? Ugh. That does not sound pleasant to me.
THIS! thank you! I will now put more energy into learning to search the history. Any more basic power tips would be wonderful. My current workflow is very cumbersome and I know I'm wasting time on things an expert would not.
 
Old 01-14-2024, 07:27 PM   #20
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by disk_bearing View Post
THIS! thank you! I will now put more energy into learning to search the history. Any more basic power tips would be wonderful. My current workflow is very cumbersome and I know I'm wasting time on things an expert would not.
First tip - ctrl-r for command history search. Each user has a bash command history, which you've probably noticed you can access by pressing UP ARROW and DOWN ARROW. Command history search simply lets you really quickly find a previously typed in command by substring search.

You just type CTRL-R and then start typing the string you wish to search for. It will first show you the most recent usage. Press CTRL-R more times to find older usages.

So let's say I had typed in

Code:
cd /media/kuo/Data1000/Mo/minecraft/saves/
some time in the past. I don't feel like typing the whole thing again so instead I press CTRL-R and then Data1000 to find it. At that point, I may edit the command or simply press Enter.

Second tip - symlinks

You can quickly create a symlink in two ways:

Code:
ln -s /media/kuo/Data1000/Mo/minecraft/saves/
ln -s /media/kuo/Data1000/Mo/minecraft/saves/ Data1000saves
The first way simply names the symlink the same thing as the target (in this case, "saves"). The second way explicitly gives a different name for the symlink. In this case, I may want that because there's already a "saves" symlink or I with to know more at a glance about where it's pointed to. Or maybe I've set up a script that assumes a particular symlink name.

Either way, you can see the target of a symlink with "ls -l".

There is a gotcha with using symlinks, though. When you start doing "stuff" inside a symlink, bash really does think of its current path as using the symlink, not the original path. This can potentially cause weird issues for other users who don't have the same symlink, or on other computers where you don't have the same symlink.

To avoid that, use the -P flag. Here's an example:
Code:
kuo@ella:~$ cd ~/c64stuff/
kuo@ella:~/c64stuff$ cd -P ~/c64stuff/
kuo@ella:~/tempo/working/dev/c64/c64stuff$
I have a symlink in my home folder named "c64stuff".

In the first case, after I "cd" to it, my current path is /home/kuo/c64stuff. If I do anything that references that path, it might be broken later if I delete or change that symlink.

In the second case, after I "cd -P" to it, my current path is /home/kuo/tempo/working/dev/c64/c64stuff. Oof, that would have been a lot of typing/tabbing! But now, anything that references the current path doesn't care if I later delete or change the symlink.

The "-P" flag is most useful if you are just setting up some temporary symlinks to conveniently "get to" a path that you wish to work on for some time.
 
1 members found this post helpful.
Old 01-14-2024, 08:28 PM   #21
disk_bearing
Member
 
Registered: Mar 2022
Posts: 37

Original Poster
Blog Entries: 2

Rep: Reputation: 2
Awesome! I was struggling with symlinks until I started using
Code:
ln -snf
Should there be a command line nav thread?
 
Old 01-15-2024, 02:41 PM   #22
disk_bearing
Member
 
Registered: Mar 2022
Posts: 37

Original Poster
Blog Entries: 2

Rep: Reputation: 2
All this time I could have had symlinks in ~ Thank you all, this is gold
 
Old 01-29-2024, 11:58 AM   #23
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,819

Rep: Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211
Back to the $var <tab> \$var problem.

Try to upgrade or downgrade your bash package!

I think you have to wait for a bug fix.
In the meantime, try out the zsh shell.

Code:
zsh
emulate bash
starts a zsh and tries to emulate bash. (exit or ^D will return to the parent shell)
Then try-out the $var <tab> there!
And enjoy the cursor-up! It leaves a multi-line (e.g. a loop) untouched. Unlike bash that re-formats it "inline" (and there are bugs with it).

Last edited by MadeInGermany; 01-29-2024 at 12:14 PM.
 
1 members found this post helpful.
Old 02-06-2024, 09:10 PM   #24
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,365

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
If I have frequent cmds to run and or dirs I need to get to easily, I use an alias in my .bashrc eg
Code:
alias cdcl='cd && clear'
alias qa-dev='cd /Users/username-here/qa-dev-envs/qa-dev'
and then invoke the alias as a cmd.
 
  


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
LXer: The first browser to introduce a second level in the tab bar for managing tab groups: Two-Level Tab LXer Syndicated Linux News 0 03-01-2021 05:50 AM
adding an option to a 'tab' completion + ls whatnoname Linux - Newbie 2 06-07-2005 07:32 AM
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
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 11:57 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