Showing 155 to 158

Stupid tricks to quickly learn Eshell and Dired

Eshell, Dired, Never learn Bash

Maybe no one told you, but Dired and Eshell go together. Try to learn just one without the other, and enlightenment will be tardy.

For faster enlightenment:

  • Realize that there's effectively no prompt as far as the shell is concerned, they're just bookmarks for prompt nav commands. Try having a blank prompt for a while (prompt nav commands won't work) until it feels normal.
  • Forbid cd. It's not sufficient to "try to use it less"; either run something like alias cd=echo in .bashrc, or have cd open a Dired buffer for the target.
  • Forbid ls, or have ls just switch to the Dired buffer for that directory.
  • Have a good hotkey in Dired to open the Shell buffer for the present directory, creating the buffer anew if necessary.
  • Have a good hotkey in Shell to open the Dired buffer for the present directory—or you could content yourself with the ls command doing that.
  • Previous Dired and Shell buffers should always bury themselves at the bottom of the buffer list! They would flood it otherwise.
  • You'll notice that your shell buffers will be cleaner, with no trail of cd or ls output, and this may have made the scrollback more interesting. That ties into the next point: when using the shell, aim to never repeat a command. Decline to engage in the ancient workflow of iterating on shell commands, trying different switches and building pipes incrementally. In fact, you could set a counter for eshell-send-input (RET) such that you can only send 20 commands per day, and display this counter in the modeline or prompt.
    • Learn emacs-piper – it won't be needed as often as you think, but it's great as your last weapon.
    • Learn the hotkeys for navigating and manipulating the output. In particular:
      • C-c C-p – jump to previous prompt
      • C-M-l – similar, but jump to top of last output (better)
      • C-M-j – my-ins-oth-buf-fil-nam
      • C-c RET – more on this later
    • Instead of building pipes like ls -l | grep .jpg | cut -f1, use C-c M-o (eshell-mark-output), narrow-to-region and carry out the appropriate buffer-editing commands to get the same result that the shell command sequence would have. This is the hardest part by far, but the skills you gain in text transformation are general and carry over everywhere.
    • Learn to operate on the custom output you've munged – or even on any text, for example an Occur or EWW buffer – save it into a Lisp variable 'var, and access it as $var in eshell. Write custom functions to instantly pipe selected region to xargs. That sort of thing.

More, if you like going off the beaten path:

  • Save the shell scrollback per directory
  • Save the shell command history per directory
    • A side detail: keep track of the commands you've used the current session. They should be appended to the open directories' histories, regardless which directory they were used in.

if you follow the earlier advice, every directory already gets its own shell (remember that you disabled cd). With this last advice, when you enter a new directory's shell, you may be shown scrollback from weeks ago! Relevant or not, it can be fun to see, and anchors you in the passage of time. If you realize you wanted to use the output from earlier commands, from before you changed directory… simply go back to the previous directory's shell and grab it (hopping between shells should be a hotkey, that's faster than cd .. and cd -). Of course you'll still want the recent command history, things you used just minutes ago in another directory, which is why they should be brought along on the ride. The difference from usual history-tracking is that only the commands this session get saved to only those directories in which you have opened a shell, which is going to be a minority of all the directories you've visited with Dired.

I could ban the pipe (|) operator as part of a learning process for text munging.

What links here

Created (6 years ago)

What I'd tell past-me about houseplants

Use standard unpainted clay pots

They have much less risk of overwatering, due to multiple factors:

  • The walls breathe
  • The conic shape means there is less dirt at the bottom to get waterlogged
  • The drain hole gets rid of the excess

That matters because watering should be dead easy, especially when you have to travel and let someone else water your plants for a while.

If I cannot have this, I must have a glass pot so I can see how much water is inside.

Use big plates

Re. the pot-and-plate method. Big plates let you water plants "from the bottom up": you fill the plate with water and let it be sucked up into the soil. Watering this way 3 weeks out of 4 keeps the topsoil dry most of the time, which discourages gnats (fruit fly-like pests).

When you water top-down,

  • It carries soil out into the plate, making the standing water more dirty and contributing to plaque buildup on the outside of the pot. Always water bottoms-up and there should be less of this type of plaque.

When you commit to watering bottom-up,

  • any decorations you put on the topsoil will stay clean. so you can:
    • add water-vulnerable decorations, like paper artworks
    • style it like a Japanese stone garden
    • etc

Sanseveria / snakeplant / mother in law's tongue

Give it a good deep pot. In a shallow pot, it ends up splaying rather than standing straight up.

If you want window plants, this plant is one of the best, because it doesn't twist its prettiest side to face the window. It also handles rough transportation without any trouble, good if you move often. Spiderplants break apart if you so much as look at them.

Golden pothos / devil's ivy

The vines can be fragile. Specifically, when you have a side shoot growing out of another vine, that side shoot is forever at risk of snapping off, even if it's grown to a healthy 8-meter beast. The connection to the parent stem is still so weak that a flick of your finger can be its end. In nature, this is fine because the vine is supposed to be securely wrapped around a tree trunk or some such, so jostling a part of it will not jostle the entire vine.

For a pothos in the home, it's nice if the main stem(s) are be responsible for most of the plant mass. If you have side-shoots near the base, bury the base in a lot more dirt. The dirt will keep things from jostling and breaking. If this is not realistic, stick the vine's tip into a new pot where it will start over more strongly. Bury the tip deep!

Or find some kind of safe sealant to strengthen where the side shoot branches off from the parent stem.

Spiderplant

Unless you like the weeds look, don't get these. It can be very pretty if a single spiderplant grows in the middle of a pot and has not been jostled or touched since birth, but as soon as someone touches it or looks at it wrong, leaves start bending and breaking and now it looks like weeds.

With opaque pots lacking drainage, make a reservoir and watering tube

If you must use an opaque pot lacking drainage… do it right. It's hard to improve later.

Rig a water reservoir in the bottom and install a watering tube.

((If you don't want to bother, a good minimum is to stick a pipe through the dirt, so you can pull it out and make a proper watering pipe at some point in the future.))

It's easier than you think. Ingredients:

  • a wine cork
  • a plastic pipe
  • some steel wire
  • expanded clay balls (or round balls of any kind)
  • some old nylon or polyester clothing you can cut up

Put the pipe in the pot, making it stand perfectly vertical.

Cut the cork down to something that will fit inside the tube.

Stick a steel wire into the cork. Drop the cork into the tube so it hits the floor. Don't cut the wire just yet.

Fill the pot up with a few centimeters of clay balls. Then add water until it matches the same level.

At this point the cork will be floating in water. Now cut the steel wire at the exact point it exits the tube. That's your marker! That's how you see that the reservoir is full.

Put down some nylon or polyester like a mat over the reservoir, blocking roots from growing down into it. If you can, seal tightly around the tube and also line the walls, but don't be a perfectionist… it's just a plant.

I prefer pots with drain holes or glass pots, it sidesteps all this work.

With climbing vines, consider initial setup

Pole

Want a pole for it to climb on? Install it before you need it, i.e. when the plant is still young. That also lets you center the pole in the pot, which is impossible later.

You might be tempted to use a broken broomstick or something else lying around, but pick a material that won't rot or rust. A plastic broomstick or a PVC pipe is good. You can even take a short pipe now and a longer pipe later inside the first pipe. Make it a thicker pipe than you think you'll need, having a too thin pipe is the kind of mistake that's hard to fix later. I mean, now you imagine a half-meter pole, but what if you want to extend that to eight meters (the maximum length of a golden pothos vine) at some point?

Where to put it

For any climbing plant, bonus point if you can find a permanent spot for it (ideally a corner) and let the vines climb the walls. Vines like climbing on things and this encourages the leaves to grow big, I hear. This may scrape the wall surface, so decide if it's worth it. Further bonus if you're willing to spray water directly on the walls: aside from motivating the vines to use the wall, this gives you the freedom to apply and rinse off insecticide without moving the plant.

When you buy a new plant

Check it at the shop. Undersides of leaves, etc.

Bring it into the house in a plastic bag. Wash yourself since you've been at a greenhouse.

Quarantine the new plant for 40 days. If you don't have an extra room, you can put a plastic bag over the pot.

Pest prevention

  • Water bottoms-up
  • Quarantine new plants
  • Quarantine sick plants
  • use insecticide as needed
  • use soapy water and rinse
  • use clean pots & clean soil (sterilize it yourself). Consider non-soil potting mediums too.
Created (6 years ago)

Noob Guix' Checklist

Computing

AIMED AT: users who have gone through the basics and installed the system, but are still confused about things

Guix has not much in the way of end-user tutorials that tell you how to operate in day-to-day life. So you easily miss obvious things. We can't learn everything all at once nor see the best way to work even if we know roughly what commands exist. What follows would have prevented problems I had for far too long. Give it a gander in case you are suffering like I did.

I'd like to grow this list. If you have suggestions, email me!

Root vs user profile ??? I'm confus!

No, you don't need to run guix pull both as root and as your main user. Here's a full system upgrade:

guix pull
guix upgrade
sudo -E guix system reconfigure ~/config.scm

Using sudo with the -E flag means you'll be using the user's copy of Guix, thus root does not need to do a guix pull. Do remember that root's copy is outdated if you ever log in to root on a tty (just don't do that).

(<2022-Jan-23> OK, pretty sure the -E flag is not even needed)

Loading

How best to load your own package definitions? In short:

  1. Don't set the shell variable GUIX_PACKAGE_PATH – forget about it altogether – instead, set up a private channel (see the manual).
  2. In addition, be familiar with the -L (--load-path) flag.

That's because you are solving two separate problems:

  1. Always having access to your privately defined packages
  2. Quickly iterating on new definitions

Quick iteration from a private channel is slow, because as of <2020-Mar-22>, guix pull does not have a setting to only pull the local channels, so you have to wait for it to update all your channels, pulling things over the network and calculating a new package graph, and god forbid there's actually an update to Guix.

In principle, GUIX_PACKAGE_PATH solves both problems, but it introduces its own problems: Guix gets no ability to version-control your packages (as it does with a channel), it's a bigger hurdle to publish your packages, and as of <2020-Mar-22>, it causes every Guix command to complain a lot about "source file newer than compiled".

Ok, show me

So, let's assume you have this directory structure for files containing your package definitions:

~/my-channel/me/emacs-xyz.scm
~/my-channel/me/machine-learning.scm
~/my-channel/me/various.scm
~/my-channel/.git

Those *.scm files contain the top-level expressions (define-module (me emacs-xyz)) and (define-module (me machine-learning)) et cetera – the module names have to match the file and directory names.

Next up, the following content of ~/.config/guix/channels.scm will give you access to your packages. Plug and play.

(cons*

  (channel
    (name 'me)
    (url "file:///home/me/my-channel/.git"))

  %default-channels)

That's all good when your package definitions work. But when I am writing a new package, I run into errors maybe twenty times before I get it right. So during this process of iteration, instead of repeatedly git-committing and guix-pulling, load the directory directly, sidestepping the whole channel concept:

guix package -L ~/my-channel -i MY-EXPERIMENTAL-PACKAGE

Or, for example

guix build -KM 5 -L ~/my-channel MY-EXPERIMENTAL-PACKAGE

That's it. The additional flags are a bit off topic here, but -M 5 (--max-jobs=5) simply lets there be 5 concurrent build jobs so it'll build faster. The -K (--keep-failed) means that on a failed build, it'll tell you the path to the build directory, so you can see what got built and what didn't, what the configure variables are etc. An use case is when you're trying to modify a Makefile procedurally in the package definition (e.g. delete a few lines) and want to visit the actual Makefile to check that the modification had the intended effect.

I recommend shortening all that to a quick command, let's call it "test":

alias test="guix package -KM 5 -L ~/my-channel -i "

Then you can just run test PACKAGE every time you edit the definition for PACKAGE.

How to get help

You often find no help by Googling? Here are two places to get info, far more reliable than a generic web search:

  1. The #guix IRC channel logs
  2. The mailing list archives, particularly help-guix but also bug-guix lists.gnu.org/archive/html/

Download the entire chat log of the #guix IRC channel. Many, many times I've got answers by ripgrepping that directory.

Manpages

Especially when you keep separate package profiles/manifests, you might find Man pages and info documentation absent. To fix, every manifest (in addition to the main user profile & the system-wide profile) should contain at least the following packages:

  • man-db
  • info-reader
  • pkg-config

I'm not sure if there's a better way to do this.

Created (6 years ago)

Eshell's unnamable quality

There are many great packages. Packages like smartparens and company, that extend Emacs with invaluable functionality. But some packages are special, because they do more… they extend Emacs' extensibility. They increase Emacs' potential, make it applicable to more domains, let you slurp up more of your operating system and add opportunities for code reuse.

Some of them are:

  • eshell
  • exwm
  • exwm-edit
  • piper

These packages touch on a grander concept I will introduce shortly, but first I must explain what I see in Eshell.

The Way of Eshell is to abandon the concept of a terminal emulator, abandon the past and move into the future. The project has no plans to support escape codes (aka control codes) or interactive behavior, because controlling the shell buffer in realtime is considered out of scope for commands run by the shell.

Commands should be simple input-output machines and have no knowledge about their context. There is no need for each command to have twenty different command-line flags to shape the output into the form you want it – that's better done by an universal text-shaping tool, such as a text editor. You can alternatively use Unix commands like uniq, column and sort, but once you've exhausted what the commands can do, you may still have to make ad-hoc changes to the output as if in a text editor, so why not be in a text editor while you're doing it?

And better, once you're done editing the output with your everyday text-editing skills, you should be able to pipe it into another command without running into doubts as to which combination of echo, tee, xargs and cat applies this time (doubts strong enough that many have never thought of piping into vi). So you get to have a command pipeline without having to execute the pipeline in one step!

You don't need to iterate in a "compile-cycle" process until you get the whole pipeline just right. You can see what happens at each step, you don't need to pollute your shell history with irrelevant failed attempts, you can hone your text-editing arts, you'll have access to all the info your editor knows (say, the name of the file that's currently open in another window), you don't need to look up the specific shell commands to extract a specific piece of git information or system information (because you can get that info the same way you always do in your editor), and you'll never need to learn about commands like uniq, column or sort, or for that matter what even is Unix. Unix-nostalgia aside, that is scalable, beautiful and future-proof.

When you learn to abandon the Unix tools in favour of a more reusable and extensible workflow, you'll glimpse the deeper Zen underlying Emacs. The article Programs Are A Prison explains better than I can. Notice that it mentions that a good program should be "invisible", that it should lack boundaries, and eshell is a vivid example of that. Eshell is a much less distinct "application" than an external terminal window, and less distinct than ansi-term and even the polite shell mode. There is less of a sense that "Now I'm in the shell" or "Now I'm out of the shell". Its buffer is as malleable as any other buffer, and since you may do part of your command editing in separate buffers from eshell itself, it blurs the boundary of where the shell begins and ends.

What links here

Created (6 years ago)
Showing 155 to 158