Quote:
Originally Posted by disk_bearing
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.