Scripts to be "quick and efficient" - Servers Administration, Networking, & Virtualization

Users browsing this thread: 1 Guest(s)
Hello fellow nixers,
In this thread let's share our opinions on those brand new tools for "efficiency" that pop-up so often on tech-news websites.

I'm referring to scripts aliasing, prettifiers, curses wrappers, helpers of all sorts, fancier interfaces over old tools, etc..
Especially tools that are made to make other tools more usable or prettier.

Tools and scripts such as:
Here's my stand on this topic:

I don't usually install any of those fancy wrappers for efficiency purposes because I keep switching between machines while working and I can't be bothered to install one in a place and not the other. I'd rather stay vanilla.
However, I still have maybe two or three color wrappers such as colordiff that I use quite a lot before sending patches or pushing online my changes.
Tools are tools in the end, if you can extend your environment to fit what you need then it's for the best. CLI are also easy to write so it let's anyone contribute with new tools.

Share what you think of tools wrappers and prettifiers, and don't forget to mention some of them too.
Grey Hair Nixers
tldr; emacs

I have been adopting a slightly different approach than mentioned above --
pulling more and more into the emacs interface, and using the plugin tooling
there. This gives me a relatively consistent interface to many tools without
having to learn different ncurses silo-type programs or install things on remote
machines. buffers, modes, keybinds, input, display are all handled in the
'emacs' way, so I can try out different plugins with not so much effort, and
extend what I don't like.

some highlights (in the flavor of the above tools):
- I no longer run terminal emulators by default -- instead I run emacs shells.
This means that I can treat STDOUT as text, manipulating past output for reuse

- magit[1] is a good git interface that can do all I like (diffing,staging
regions/lines, branching, stashing..)

- restclient.el[2] is a nice http request wrapper that lets me execute requests
interactively and store them as text, giving me a postman-like experience. it
even allows elisp code in the mix so I can use stuff like pass[3] for auth.

- tramp mode [4] gives me a remote shell within emacs so I can use my tools
without having to install anything on the remote machine. I just add aliases
to shx[5].

When I look for tools like the above, my focus is on shortening the feedback
loop in whatever I am doing. The faster I can iterate on an idea/interact with
something the faster I can change and adapt. Having a consistent interface for
many things lets me do that.

There is much more, I don't want to wax too long if there is no interest here.
my config:

Long time nixers
A tool that requires me to add a lot of scripts to be sufficiently pleasant will eventually be replaced by one that doesn't. Examples:

- I moved on from Vim to other editors when I found that I spend too much time in my .vimrc, stealing productivity.
- I am still in the process of moving on from GNU Emacs to other editors as I found that I spend too much time in my .emacs, stealing productivity.
- I am evaluating shells like fish for interactive use because they work out of the box exactly like I want them to, without "oh-my-something" and/or a shitload of plug-ins. For a very similar reason, I have resorted to the PowerShell on Windows now. It just works.

Opposing Zawinski's Law, one application at a time. (Also, probably, contradicting myself. Life is a flux.)
Long time nixers
(03-09-2018, 08:43 AM)jkl Wrote: I spend too much time in my .vimrc, stealing productivity.

This is an interesting point, It's true that customization and productivity do not perfectly correlate, but many of the additions that people make to their .vimrc or .emacs are worth their time.

At what point does customization stop being an investment into your productivity, and start stealing productivity?
Long time nixers
If your editor configuration needs more than two changes, your editor is probably the wrong choice for you.
Grey Hair Nixers
(03-09-2018, 10:02 AM)jkl Wrote: If your editor configuration needs more than two changes, your editor is probably the wrong choice for you.

right -- this view in my mind leads to the mindset of the OP -- install a new tool/editor that does do what you want, rather than do the editor configuration on your current one. I would rather do the latter.
(03-09-2018, 09:09 AM)Steph Wrote: At what point does customization stop being an investment into your productivity, and start stealing productivity?
This is the crux of the question for me.
A lot of the tools/script/wrappers like the ones I mentioned in the OP aren't necessary but are for the eye-candy or to not have to learn the underlying command properly, maybe making it faster at the same time.
Not that there's anything wrong with that but you have to weight if it's worth it to add something on top of what you already have. It's the same kind of thinking about the IDE vs Editor+environment sort of talk, which is probably the reason why it was brought up here.

You can't run away from things you need to do your daily tasks on your machine now it's up to you to choose if you want to build that functionality from scratch or add wrapper around what you already have. I guess there's a balance.
Like jkl said:
(03-09-2018, 08:43 AM)jkl Wrote: A tool that requires me to add a lot of scripts to be sufficiently pleasant will eventually be replaced by one that doesn't.
If the tool gets in the way of your activities and is being unpleasant, that's when I'd start to think more about my usage of it.

It would be nice to hear from someone who uses a lot of those eye-candy and script wrappers tools to hear what they find appealing in them.
(03-09-2018, 10:02 AM)jkl Wrote: If your editor configuration needs more than two changes, your editor is probably the wrong choice for you.

This is like buying a different car because the seat didn't come adjusted the way you like. Spending time to configure your tools is a worthwhile investment. I've spent maybe a few hours total configuring VIM and rarely need to tweak the configuration.

But the bigger time investment is learning how to use your tools. Crack open a man page rather than reach for an alternative. If you find yourself spending too much time configuring your editor, it might be time to step back and question if you're using it correctly.
Grey Hair Nixers
> At what point does customization stop being an investment into your productivity, and start stealing productivity?

The only way to get a gauge for this is practice and experience. When I first started customizing and automating things, it took forever and I was slow, and learning (and still am!). but now when I want to enhance my editor or script a task I have a handle on how long it will take and if it is worth doing, and can be honest with myself if this is really to be efficient or if I'm just looking for some fun (because it is pretty fun).
Long time nixers
(03-09-2018, 10:02 AM)jkl Wrote: If your editor configuration needs more than two changes, your editor is probably the wrong choice for you.

Why would this apply to editors, especially OS-ish editors like Emacs, but not real OSs? I barley know anyone who could just use a bare, unmodified linux install (putting preconfigured distros like Ubuntu aside), maybe OpenBSD people could manage it, but I'm not sure.

I have a quite extensive .emacs, and sometimes I might spend more time working on it that I would immediately want to, but I rarely regret it. Why? Since it helps me in the long term, which is exactly what customizations are about.
Long time nixers
I haven't used bare, unmodified Linux installations in years and I don't regret having moved on. However, what is it that you need in a text (or code) editor? Even GNU Emacs works rather well without any configuration changes. (If you can live with its defaults. But I don't like the colors...)
Long time nixers
(06-09-2018, 07:44 PM)jkl Wrote: But I don't like the colors.

I'm in love with my E-ink theme
Long time nixers
(06-09-2018, 07:44 PM)jkl Wrote: However, what is it that you need in a text (or code) editor? Even GNU Emacs works rather well without any configuration changes. (If you can live with its defaults. But I don't like the colors...)

Stallman explains it quite well (source:

Quote:EMACS could not have been reached by a process of careful design, because such processes arrive only at goals which are visible at the outset, and whose desirability is established on the bottom line at the outset. Neither I nor anyone else visualized an extensible editor until I had made one, nor appreciated its value until he had experienced it. EMACS exists because I felt free to make individually useful small improvements on a path whose end was not in sight.

what Emacs is couldn't have came into being, it's a core aspect of Emacs (source):

Quote:By Stallman's own recollection, the macro hack touched off an explosion of further innovation. "Everybody and his brother was writing his own collection of redefined screen-editor commands, a command for everything he typically liked to do," Stallman would later recall. "People would pass them around and improve them, making them more powerful and more general. The collections of redefinitions gradually became system programs in their own right."

Of course the standard configuration works well, but depending on my use case, I might want things to be different or to do entirely new things, either because of my own intentions or my personal environment. Examples would be something as simple as rebinding M-SPC from
or using input modes to easily write german words anywhere I use Emacs.

In the end, it's just a very, very big shell.
Grey Hair Nixers
I moved away from vim when I realised that I could easily spend an hour per day tweaking my .vimrc. Be it searching for scripts, color scheme or rebinding stuff.
I'm now using vis for years now, with the default config and it works perfectly.
I'm slowly (but surely!) moving my toolset to the ALL DEFAULTS! way. No config file is the easiest way to deal with configs ;)

To go back to the original topic, I have tens of scripts to make me quicker and more efficient.
Of course I have my own `diffcolor`, but the one I use the most is a script that crawl my /etc/hosts and $HOME/.ssh/known_hosts, and pipe them in `pick(1)`, a fuzzy selector. It then let me ssh in a host directly.
I bound it to ^K in mksh, so I can connect to any host in seconds (it makes all my collegues jealous hehe).
I use a similar system with `dmenu(1)` to open bookmarks in my webbrowser, or browse my history. It let me acces web resources in just one keybind, without needing to focus an app.

On the efficiency level, I also added these lines to my .ssh/config:
addkeystoagent yes
forwardagent yes
Now my keys are automatically added to my ssh-agent the first time i use them, and the agent is always forwarded (it helps me send files between hosts directly without having to retrieve them locally).

The last thing I did was to create a "plumb" script, bound to button4 on my mouse (on the side, near thumb). It reads whatever is in the primary selection amd open it. It works on local file path of course (ala xdg-open), but I use it mostly for web links. Instead of openning everything in the browser, it will download the file (or in the local apropriate application: media player, image viewer, text editor, ...
This way I can use.the full power of each app instead of relying on the web browser!
For the curious, here is an earlier version of this script (now named "plumb" in hommage to plan9):
Long time nixers
Wouldn't it have been easier to just use Acme for that?
Grey Hair Nixers
(08-09-2018, 08:21 PM)jkl Wrote: Wouldn't it have been easier to just use Acme for that?
Aqme is a text editor at its core, which is not what I was looking for. Also, using aqme to plumb selection would require aqme to be open all the time, which is not acceptable to me.
Also, I don't like aqme much with the fact it's mouse-driven.
Long time nixers
i became too attached to my customizations for them to be worth it as i distrohop more than i would like to admit. so i gave up on customizations because it takes too much to reconfigure or restore configurations if you need to rebuild your os. and this very much so applies to the os. i try to stick with default packages as well as default configurations. it just becomes too much effort to keep track of all i use and how i use them.
Long time nixers
for me, optimizing my {workflow,environment} is cathartic. making my setup visually appealing and working the way that's best for me helps me improve. it's an iterative process. if i dont try out new tools and evaluate new methodologies i cant accurately gauge what works best for me.

on top of that thought and experience activities where you force yourself out of your normal comfort zone can give you better perspective. things like our "week in the tty" challenge. i had considered myself a shell user until the 1st time i tried it. i realized how much i relied on things like xsel to jump-gap my clipboard between applications. after a few days w/o using x i gained new powers i didnt realize i "needed". now when i connect to a remote or headless box i'm much more agile and able to work w/o relying on applications i have locally. that being said, it also shows me how far {i,we}'ve come and how much i love tools in my kit.

when i first, seriously, decided to switch from {gui,ide like} editors to vi{m,} my guru z3bra gave me some sage like advice. "learn to use vanilla vi first. once you master the basics everything else will be a natural extension of it's capabilities" <i paraphrased him>. i was naive and didn't fully grok what he meant at first. but after years i've finally started to become enlightened to his wisdom. fast forward to the present my vimrc has changed quite a bit. and i use neovim locally with a bunch of plugins. the features i've added to the editor are lovely and help me a lot for my work. but none of them are "necessary" to me getting things done. now when using vi on an ancient server somewhere i still feel right at home. sure, it's not as "flashy" but as a tool it works just how i expect it to.

speaking of aesthetics; for me, having "good colors" is very important. i read better w/ light on dark colorschemes. for things like your gkt theme and terminal colors this can be achieved w/ relative ease. but for the web it's not so easy. i spend a decent amount of time using the same websites both at home and at work. so taking the time to write css overrides for those sites to make them match my color schemes is worth it to me. there's nothing worse that going to a site and being blinded by some neon white bg. the same is true with distilling visual information. i like to {remove,hide} entire sections of sites to help me focus on only the content i care about (e.g. make reddit more like lobsters).

now, to the actual topic of this post :P

i have a variety of shell scripts in my ~/bin folder that i use all the time. but they mostly just help me automate tasks i cant be bothered to remember to do manually. things like {dis,en}abling my touchpad or discrete graphics cart on my laptop, interacting w/ remote {pastebin,shortlink} services, or just fun stuff like processing and displaying terminal {ascii,ansi} art.

my real productivity enhancements have come from optimizing my toolchain and workflow.
(08-09-2018, 08:05 PM)z3bra Wrote:
addkeystoagent yes
forwardagent yes

The agent forwarded on the remote box now has access to all your keys -- i.e. some other root user on one of your work boxes can run:

sock=`ls -l /tmp/ssh-* | grep $YOUR_USER | awk '{print $NF}'`
SSH_AUTH_SOCK=$sock ssh
echo commence lulz...

A bit ago I wrote an inelegant hack to deal with this
I just checked the link for bat in op, assuming it to be some kind of battery display tool. I know that the `cat -v` thing is pretty funny now, but I honestly don't see the point in this at all. (if you didn't check the link, it's "cat with wings"). If I want to stick text files together or quickly view in a shell, I'll use cat. If I want to view/search it, i'll use less. If i want to edit it or do anything more, I'll use vi.

Since my introduction post, I used emacs less and less. Like z3bra, I think that the more I can cope with no config, the better (still want a monochrome setup though). Using vi has been an experience. I don't have syntax highlighting, but I prefer it without to be honest.

Mostly I do use a fairly vanilla system setup, which is even easier with Openbsd which comes with lots of good things by default. I add a couple of the suckless tool because I'm used to them. And a browser, and also git (it's kind of a necessity, whether I like it or not).

like xero said, colors on the web is difficult to get right. I haven't written any particular css overrides, and kind of just stick it (most of the web I use now is accessible through lynx, or rss ). I tried removing all css and applying some standard styles, but the amount of non-semantic html elements used these days makes it difficult for it to work on a lot of sites.

generally I don't like helper tools as it makes everything uncomfortable on other machines. on my own machine however I may add a few quality of life things just to make things take less time, but I don't like to get too attached.
Grey Hair Nixers

I'm using one ssh key per host for my personnal usage, and don't use agent forwarding to prevent that.
At work it's a different story though... I'm part of the team that has root access to all machines, and I don't see why someone would steal my key. Theu can su(1) as me anyway, amd connect to the same machines as me, so it doesn't bother me at all that they can access my auth socket ;)
I used to futz with configs constantly to "prettify" everything, things like hyper-confiured oh-my-zsh and .vimrc. These days I just want to work, and pretty systems are too time consuming. Some ways I've done this:

- Used vim-sensible to start a vimrc for me that needed five minutes of change one time and then never touch it again
- Plain old ksh with almost no configuration save my prompt. I don't need all that nonsense cluttering my term
- qutebrowser as it does everything my addon-laden Firefox does and with 10% of the resources
- vscode on Windows at work, since I spend most of my time writing PowerShell and Python and both work with a one-click addon
This came up in my feed recently:
What's your take on those, do you recommend any of the tools listed, do you have one installed?
(17-06-2021, 01:56 AM)venam Wrote: What's your take on those, do you recommend any of the tools listed, do you have one installed?

Out of all of the tools listed there I have only tried jq and tbh I'm not really a big fan of these "modern" unix tools. For example, I definitely don't need git integration when quickly checking a file with cat and relying on some ranking algorithm when navigating directories is just an horrible accident waiting to happen. Also also, while I can agree that some programs don't have the best man pages, tools like tldr are absolutely ridiculous to me because I think it just shows that you couldn't be bothered to take 10 seconds out of your day to read documentation that someone has spent countless hours on.
(17-06-2021, 03:11 AM)s0kx Wrote: I have only tried jq
I am trying jq, I like it so far, it's nice and minimalist and fills a need that wasn't covered by the classic tools. The way I used to prettify json before that was by piping to python -m json.tool but it doesn't have filters.
Long time nixers
Except for filters like jq, most of those modern tools are not scriptable. They are just TUI (like bottom and gtop) or pretty printers (like bat), that should not be used in a pipeline, but should be used alone in an interactive shell.

There's, however, a new type of filter that are in vogue nowadays: interactive filters. Utilities like dmenu(1), fzf(1) and pick(1) that, rather than process their input and generate an output, let the user do that. Interactive filters are something new and a pretty much unexplored domain of utilities.
Long time nixers
(17-06-2021, 01:56 AM)venam Wrote: What's your take on those, do you recommend any of the tools listed, do you have one installed?

I use bat (aliased from cat - technically, bat is a less replacement, but for interactive use it is what I usually want) and ripgrep regularly because they add some convenience over the standard tools. I also have fd installed, but I never use it. I should probably remove it again.

The thing with most of these tools is that they focus on integrating Git (which I don't use) and/or adding more colors (which annoys me a lot). The most useless tool in the list is exa. None of its most interesting features are not part of colorls.
I find it odd that in that list it seems the word "modern" is synonymous with "colourful". I agree with phillbush, many of these new tools are not scriptable.

Other than that, it's a good thing that most of these tools are aiming for a more user friendly interface. However, it would be unfortunate if someone finds the traditional *nix coreutils too difficult to use and turns toward one of these tools as an alternative. The coreutils are important to master since they're available on most (*nix) systems. One example is grep(1) which is an incredibly useful tool to gain fluency in, as most systems don't ship with ack, ag or any other grep-like.

On the other hand, are we really gonna use the tools they used 40 years ago forever? I think it's good that people are trying to innovate, but I don't see much innovation in these new tools. Most of them are, as I alluded to earlier, just colourful variants of traditional command line utilities. Some of the other utilities like tldr and cheat seems to be fulfilling a need: Better documentation in the StackOverflow style of asking simple questions about usage without having to sift through a man page. This presents more of an issue with the popular style of documentation found on UNIX-derived systems today, which can be greatly improved. Just look at GNU info, the introduction of hypertext in documentation is an amazing addition.

I'm starting to think that the interaction method of the command line itself is the element that is bottlenecking the innovation in this space. It's simply too restrictive. I'm not saying I'm opposed to a command line-oriented workflow; I thoroughly enjoy it myself. However, we're still using mostly the same kind of technology which was popular in the 70s even. If you want an example of innovation in this space (which unfortunately has not been carried over to *nix systems) is the command line of Lisp machine operating systems like Open Genera. It has a highly advanced autocomplete system in addition to having every part of the output being able to be selected and interacted with. It's so effective there's not even a cd(1) equivalent command for it, it's simply not necessary.