antekone
Follow

If you're using bash or zsh and you don't know the ^X^E shortcut, learn it now.

First, ensure you have a valid `EDITOR` environment variable set to your favourite editor (like vim or emacs).

Second, enter some command, but don't hit enter.

Third, use Ctrl+X Ctrl+E and learn that you can use your editor to modify the command before running it in the shell.

This is pretty helpful if you're trying to edit a long command line.

@antekone Do you know what the binding is if you're using vi input mode?

I don't need it as frequently because of vi mode but it would still be nice from time to time.

@minego @tomasino

Try setting this first:

bindkey -M vicmd v edit-command-line

They <esc>v should work.

@antekone
you don't need it if you use #acme :bloballpraisetoplan9:

but in al seriousness, Acme makes this kind of thing super easy

@antekone what's even better is that you can use it with _any_ shell:

- python repl
- chrony's console
- sh/bash/rc/fish/zsh/whatever else

it's really heccin cool

@antekone if you use vi mode in bash, hit esc-v for the same function

@antekone Super awesome. I can't tell you how many times this would have come in handy.

@antekone well, I am using vi mode in korn shell, but it is a helpful information for machines other than mine 👍

@antekone
Is this really helpful to you? As in, do you actually run command lines long enough so that standard shortcuts aren't comfortable enough?

@danipozo Not every day. But sometimes it is useful.

Last time it was helpful to me was when trying to figure out a problem with compilation of some software. I was copying/pasting long command lines that were autogenerated by CMake (several lines long).

In order to find the problem I needed to modify those command lines and see if my modification will help to get the compilation working. So I've used ^X^E and vim's substitution command (:%s///) to perform the modification. :party_parrot:

@antekone EDITOR should be set to ed, the standard editor.

For other programs there is VISUAL environment variable.

@ed1conf @ed1

@antekone Also note that, if the $EDITOR exits with a non-zero exit status, the shell won't run the command. In vim, that's `:cq`. In ed(`) (without GNU's "--loose-exit-status" parameter), any editing error will produce a non-zero exit status, meaning the command won't run. Edit with care. For all editors, if you want to abort, you can delete the entire command, save, and quit.

edit Show more

@antekone nice! you can also `set -o vi` to enable vi-like keybindings right in the shell prompt

Sign in to participate in the conversation
Mastodon

Fast, secure and up-to-date instance, welcoming everyone around the world. Join us! 🌍
Up since 04/04/2017. ✅

Why should you sign up on mstdn.io?

This instance is not focused on any theme or subject, feel free to talk about whatever you want. Although the main language is english, we accept every single language and country.

We're connected to the whole OStatus/ActivityPub fediverse and we do not block any foreign instance nor user.

We do have rules, but the goal is to have responsible users. So far we haven't had any issue with moderation

The instance uses a powerful server to ensure speed and stability, and it has good uptime. We follow state-of-the-art security practices.

Also, we have over 300 custom emojis to unleash your meming potential!


Looking for a Kpop themed instance? Try kpop.social