Substring completion on ZSH. Type in a small part of the command you want to find and then press up.
Programmer Humor
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
fish has "directory-aware" autocomplete with inlay hints and a fantastic history
command. I do not suffer from such weakness
$ history | grep 'gre[p]' | less -S
Does fuck all when you can't remember even a piece of the command lol
That's when you start spamming Page Up/Down, Home, End, and /
to search within less
. Usually seeing various commands jogs my memory, especially when they are grep
commands searching for one I use often enough to be useful but infrequently enough to not remember off the top of my head.
also when they see this post
I always go past it because I go way to fast.
I have more then once gave up on pressing up, hit ctrl + c to reset only to see the command I wanted briefly flash up as I am hitting ctrl + c
Wow this is really validating for me to read. I’ve been using Linux for a few years but I’m definitely not a computer expert and am intimidated by the command line.
I’ve always felt like googling every command and arrowing up to find an old entry rather than just googling it again marked me as a fake Linux user, not a real one.
Lol don't feel bad, I can do advanced crazy shit with Linux like pivoting the running OS into RAM so I can unmount the boot drive to do whatever without ever rebooting
But I still [Web Search] commands a shit ton of the time LMAO
You can use Ctrl-R and Ctrl-Shift-R to search through your history instead of having to push up a bajillion times.
history | grep then !cmd no
grep | history [search term]
I think you meant
history | grep [search term]
(which was id 1003 for me btw)
Oops, but yes that's what I meant.
...Yeah, you got me.
I'm in this picture, and I didn't like it....
I accidentally found out one day that I could use a wildcard operator in the terminal instead of a full file or folder name due to always doing this.
cd Pho* or cd /documents/Pho*
Will for example open my "Photo Examples" folder in the working directory or based on the path
With ZSH there's something called "path-completion" that makes that even easier.
Say you want to go to "/usr/local/share/fonts" but that's too much to type out, you can instead type "cd /u/l/s/f" and hit tab. If every path element is unambiguous it will just expand it to "/usr/local/share/fonts". In this case though, "/u/l/" can expand to "/usr/local" or "/usr/lib" so when you hit tab it moves the cursor to just after the "l" to indicate it needs you to distinguish between "/usr/local/" and "/usr/lib". If you just type "o" and hit tab again, it will know that there's only one match for "/usr/lo" and expand that to "/usr/local/" Then there's only one match for "s" which is "share", and only one match for "f" which is "fonts".
That avoids the danger of executing a command with an asterisk wildcard.
You can use ||
between two commands as well. If the first command returns exit code != 0, the second command will run.
I.e. which ansible || pip install ansible
.
Or && for if you only want the second command to run if the first command succeeded.
This only works until you grow an addiction to making pho at home and start documenting your progress.
cd "Pho Recipes and Pictures"
Being able to just enter a partial command, and hit [up] to jump to prior commands that started in the same way in zsh is a godsend.
zsh tab completion also looks through history wich is pretty nice.