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

Users browsing this thread: 1 Guest(s)
venam
Administrators
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:
* autojump
* bashmarks
* lazygit
* bat
* prettyping
* colordiff
* httpie
* and much much more, you get the idea


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.
neeasade
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
elsewhere.

- 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: https://github.com/neeasade/emacs.d

1: https://magit.vc/
2: https://github.com/pashky/restclient.el
3: https://www.passwordstore.org/
4: https://www.emacswiki.org/emacs/TrampMode
5: https://github.com/riscy/shx-for-emacs
jkl
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.)
Steph
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?
jkl
Long time nixers
If your editor configuration needs more than two changes, your editor is probably the wrong choice for you.
neeasade
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.
venam
Administrators
(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.
oda
Registered
(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.
neeasade
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).
zge
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.
jkl
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...)
Steph
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
zge
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
Code:
just-one-space
to
Code:
cycle-spacing
or using input modes to easily write german words anywhere I use Emacs.

In the end, it's just a very, very big shell.
z3bra
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:
Code:
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 tries.to 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 stream.it) 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): http://git.z3bra.org/scripts/file/link-open.html
jkl
Long time nixers
Wouldn't it have been easier to just use Acme for that?
z3bra
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.
robotchaos
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.
xero
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.
gaak
Members
(08-09-2018, 08:05 PM)z3bra Wrote:
Code:
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:

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

A bit ago I wrote an inelegant hack to deal with this https://github.com/patrickhaller/bash-ssh-agent
twee
Members
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.
z3bra
Grey Hair Nixers
@gaak:

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 ;)
evbo
Members
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