3 ms·
A bit offtopic, but anyway: The more I use the command line, the more I type full path on my commands. So (when I recall them from history) I can run them from
by lolive 9y ago
A bit offtopic, but anyway:
The more I use the command line, the more I type full path on my commands. So (when I recall them from history) I can run them from anywhere.
Next step is to store path in variables, and my command lines contain the variable instead of the path (depending whether I want the history to include the variable or the path, I will Ctrl-Alt-e the commande line before running it).
Next step is to define functions to aggregate several command lines together. And be able to replay them later. (I built a small utility to make it super simple, otherwise it is a complex time-consuming process to define and manage functions in shell).
Next step is to separate those functions into several local accounts, so tasks (and bash history) are cleanly separated.
Next step is to use screen/tmux to have one (or more) shell open for all those local accounts. (i usually have a "master" tmux, with one window per user, and each user can launch its own tmux inside it).
That sounds insanely complex. But I find a kind of calmness now.
My tasks are organized by user, histories are very semantic (each command line is a function name, very few "cd" or other non-meaningful commands).
And when I need to type commands, I think whether I will go the usual way (aka the _quick and dirty_ way). Or if I will build a clean workflow so I can replay my commands later.
- 1_player 9y agoProbably not a direct answer to your comment, but fish autocompletion has two killer features I haven't found in any other shell: 1. Type part of a command and search the history: I often have to run a mysqldump + mysql load on a couple databases, and the command is quite long. If i just type `db1` and press up arrow, fish will load the command 'mysqldump -uxxx db1 | mysql -uyyy local_db1'. I don't have to create functions to do complex, common shell commands, as long as they have keywords I can use to look them up. 2. Search the history based on the current path: Suppose I have two directories, `app1` and `app2`, each with a `run-appX` executable. If I enter `app2` and I type `.`, fish will autocomplete it to `./run-app2`, because the history is context dependent, and it knows there's a `run-app2` file I've often referenced while in the `app2` directory. Haven't found a way to replicate these two behaviours in any other shell as well as fish does, and I don't have to create separate functions for most of my workflow. fish takes care of that.
- lolive 9y agoVery interesting tricks! The first one probably has an equivalent in Bash with Ctrl-R and typing (and Ctrl+R again to cycle through matching lines) The second one is new to me. Cool!
- BenjiWiebe 9y agoI have a long command I use semi-regularly in Bash. The ctrl-r search tends to turn up the wrong command, so I edited the command and appended a unique comment. Now I just do ctrl-r, unique-comment, enter.