5 ms·
Basically, I write a script (or use an alias) for everything that I do repeatedly which would otherwise require typing more than 2-3 unique characters before us
by lcall 7y ago
Basically, I write a script (or use an alias) for everything that I do repeatedly which would otherwise require typing more than 2-3 unique characters before using tab completion. The habit just makes life easier (and is fun and relaxing sometimes). I try to use names that are quick to type (like, not the same finger repeatedly) and which are memorable, or grouping things by first characters (if there is a theme).
(This goes with the idea, which I also try to encourage, that any repeated process should be first documented in some rough form at least (like a personal note-base or team wiki), then improved over time, via improving the doc, scripting it, and moving toward full automation based on balancing considerations of cost/benefit over time, YAGNI, and avoiding debt, and ideas from the "checklist manifesto", such as the realization that even smart people can forget important things, drop the ball sometimes, or leave.)
Edit: This also lets me script away differences between platforms, so I can just remember my usual little 1-3 letter command and it takes care of the rest, while the script records the details for reference.
- iudqnolq 7y agoI've been holding off making scripts for a lot of cases so that I memorize the commands. Do you think that's pointless? I'm a college student now and I've been thinking that I'd be better off not customizing my shell too much so that I can use other computers I end up in front of. (I have nothing against customization in general, as I think my emacs would show)
- lcall 7y agoGood question. I often (not always) start the custom command name (script or alias) with the same letter as what it abbreviates, and if memorizing were my goal and that didn't help enough to remember them, I might do as you suggest. But I have enough to remember as it is, so I make backups of my scripts (as with everything personal on my main computer) using tar/gz/gpg/rsync/scp, optical media, etc., so I can refer to them when memory fails. Overall, I'd have to guess it depends on the person and the priorities, and how well one way works for you vs. the other. I currently always use a computer under my control, and over time, enough has stuck in my memory. I also want to save my hands by making things ergonomic (shorter to type when practical), as the hands are useful in the long-term. :)
- lcall 7y agoI also make notes occasionally for review, to help me remember things (like with anki, or my sfw at http://onemodel.org http://onemodel.org ), or try to make mental connections with manual pages I have read so I know where to look something up again when needed. I also sometimes go to https://man.openbsd.org https://man.openbsd.org and put in just a period ("." w/o quotes) then click the "apropos" button (optionally choosing a section) to see "what is available" and jog my memory on good tools I have forgotten. Plus somethings get used so often they really do burn in to the memory: like, I am not going to forget "ls", but I don't want to type "ls -ltr [...]" very often and it is what I want, to see the most recent entry last, so I aliased that to just "l".
- kixiQu 7y agoThe most wizardly of the wizards I work with (FAANG, though that correlates less with shell wizardry than people might think) does a lot of his ~scripting in a Vim buffer in tmux and just enters text over one chunk at a time. This is a nice approach because a lot of the time he's starting from bare bones, and always has his basic building blocks very evident so he knows them well. But, when he needs to build up a more complicated script for review, he can clean up whatever he's got. If you ask me, I'd say don't worry too much about memorizing stuff you don't use often (viva la man page), but it's great to have your common commands memorized rather than aliased for when you're helping someone else out or explaining how something works.
- lcall 7y agoCould you clarify what is meant by "enters text over one chunk at a time" and "basic building blocks very evident"? I use tmux & vim but ... unsure if I follow. Edit: Do you mean, personal, local notes on tasks, as the notes evolve into scripts? I also keep a lot of personal notes which I can export into a web site (similarly to putting into a wiki, in a very loose comparison, an example being my site at http://lukecall.net http://lukecall.net or the other at http://onemodel.org http://onemodel.org), using something like a big, efficient, outline of all my notes. (I would probably put it in org-vim like org-mode, or maybe taskwarrior, if I didn't have http://onemodel.org http://onemodel.org, which I hope to make much easier to install, sometime.) Thanks.
- kixiQu 7y agoLess structured than that, I think, but approximately similar; just chunks of bash commands (cloud services CLIs need these a lot) and different grep pipe chains, etc, roughly clumped into bash functions
- brimstedt 7y agoThe largest reason I don't do this is because I ssh into a lot of different servers and then won't have my unique aliases or scripts readily available. Is there an easy way other than copy paste to rectify this?
- lcall 7y agoIt's nice if the environment lets one have a (replicated?) shell account so you can have some place to put things (but I don't pretend at all to know if that is wise in the environment you work in). I have at times done copy/paste, or, if it seems likely to save enough time in a given situation, something like a script full of aliases that I can quickly scp over and source (". someScript") to make them available in the environment. ((or again, paste) The other comment in this discussion (do Ctrl+F for "most wizardly of the wizards") might have a good idea, but I don't understand it yet.
- lcall 7y agoTo clarify this slightly (I guess I have an urge to make a speech): it has really seemed to me, that, for the benefit of an organization (medium- and long-term), and the peacefulness & less pain for everyone involved: if anything is going to be repeated much, it seems worth making the process reliable and improving/automating it, at least a little bit each time it is performed (again, documenting, and indicating openness to peer feedback, on the path toward automating). This, to me, seems like part of the Golden Rule of working together (treat others the way one would want to be treated), as are things like not leaving useful but hard-to-maintain messes behind for others without some clarification, or having important processes that only one person knows how to do, so when they leave it is a crisis (or no one really knows how to do it so it is a crisis every time).</speech> Feedback welcome. :)