Things you didn't know about GNU readline (2019)
168 points by meribold 1 year ago | 112 comments- tpoacher 1 year agoAlong the same lines, I find this little utility in standard linux repos to be amazing. Try it on ed: `rlwrap ed`.
Package: rlwrap [...] Homepage: https://github.com/hanslub42/rlwrap Description-en: readline feature command line wrapper This package provides a small utility that uses the GNU readline library to allow the editing of keyboard input for any other command. Input history is remembered across invocations, separately for each command; history completion and search work as in bash and completion word lists can be specified on the command line.
- kragen 1 year agorlwrap is fantastic. here's a multichannel text chat system for other people who can ssh to the same host, with command-line editing, cross-session history, and logging provided by rlwrap:
the actual chat system is another 10-line shell script called `gyap`#!/bin/sh # Simple chat system frontend, wrapping gyap in rlwrap and maybe ssh. : ${GYAP_LOGFILE=$HOME/gyap.log} ${GYAP_COMMAND=gyap} if [ "$#" -eq 0 ]; then rlwrap -C gyap -l "$GYAP_LOGFILE" "$GYAP_COMMAND" "$@" else host=$1; shift rlwrap -C gyap -l "$GYAP_LOGFILE" ssh "$host" "$GYAP_COMMAND" "$@" fi
from http://canonical.org/~kragen/sw/dev3/gyap and http://canonical.org/~kragen/sw/dev3/rgyap#!/bin/sh : Simple chat system. cf. rgyap. ${nick=${1-$USER}} ${chan=${2-/var/tmp/chat}} echo "Chatting on $chan as <$nick> (override with $0 \$nick [\$chan])" touch "$chan" && chmod 666 "$chan" 2>/dev/null sign() { echo "$(date +%T) * $nick signed $1 ($(date +%05Y-%m-%d))" >> "$chan" } echo "Press ^R if a chat line appears as you are typing. Recently:" tail -Fn 16 "$chan" & pid=$?; trap "sign off; sleep .1; kill $pid" 0 sign on; while read t; do echo "$(date +%T) <$nick> $t"; done >> "$chan"
it's not secure of course; anyone can spoof anyone else or fill up your /var/tmp disk, or read the log without signing onto the channel
it would be nice to have rlwrap options to customize tab-completion, for example for expanding to recently-mentioned nicks or slapping someone around a bit with a large trout
- danieldk 1 year agorlwrap is a life-saver. Back when I was a graduate student, I contributed a system that was written in SICStus Prolog 3. SICStus was (probably still is) a great Prolog interpreter, but its REPL interface was quite bare-bones. `rlwrap`-ing SICStus made it so much nicer!
- tristan957 1 year agoI'm still not understanding rlwrap. Could you describe more about what I should notice running the ed command you posted.
- assbuttbuttass 1 year agorlwrap provides line-editing capabilities including ctrl-a, ctrl-e, and up and down arrows to recall previous commands
- assbuttbuttass 1 year ago
- kragen 1 year ago
- olau 1 year agoSome years ago I helped diagnose an O(n²) bug in readline.
For years, I had problems pasting many lines of SQL in a psql session. It would slow down as it worked through the characters. One day the same happened in another shell, and it dawned on my that this was probably a problem with readline.
So I fired up a profiler and sure enough, something inside readline was recalculating something upon each character input with the work done proportional to all the characters already input.
I sent my findings to the mailing list, and Chet Ramey fixed it.
In the process, I discovered that wonky editing of long lines when resizing a terminal window was also fixable. When you resize, you change the line width, so readline needs to take that into account when it wraps the long lines. I think it did have code to do that at the time, but it just didn't kick in for some reason. Can't remember the details, but it does seem to work fine in psql today. That was another multi-year annoyance.
- kstrauser 1 year agoIt's a relief seeing readline pulled in as a dependency for some command line tool: ahhh, there's going to be at least a reasonable amount of command history and editing features available.
To remind yourself how much we take for granted, play with `psql --no-readline` some time and see how awful it is to lose the ability to up-arrow get the last query back, edit it, and send it again.
- saghm 1 year agoIn college I had the misfortune of using the CLI that Oracle provides for connecting to their database, which had the worst UX of any CLI tool I've used by far. No history, and the only way to run a previous command was with a shortcut that ran it verbatim without allowing any editing. It didn't correctly handle commands I wanted to run that I pasted in, which meant I had to type stuff out every time, and there was no ability to delete with backspace or move the cursor backwards, which meant that making a typo required clearing everything and typing it again from scratch.
On the bright side, that experience did cause me to do a little research and learn about readline, which I hadn't realized was a library I could make use of for my own stuff before then!
- chasil 1 year agoOracle now ships a Java CLI that has all the expected modern features.
https://www.oracle.com/database/sqldeveloper/technologies/sq...
The sqlplus client continues to have all the problems that you have outlined. When sqlplus runs on the Windows command line, it does inherit command history.
- WalterGR 1 year agoOld-school MS-DOS was pretty bad. IIRC the only command history feature was pressing the right-arrow key, which would restore the previous command character-by-character.
- kragen 1 year agof3 recalls the whole command, and then you could edit it with the arrow keys and insert and delete. i think f2 x recalls the whole command up to the first occurrence of the letter x. these features existed by ms-dos 3, but i think they were in ms-dos 2 as well
in retrospect it's kind of stupid that ms-dos didn't have fantastic command-line editing and history facilities, since it had guaranteed control over the whole screen, a known keyboard layout, guaranteed at least 64k of ram, and was running milliseconds away from your fingertips without having to timeshare compute resources with other people or background compilation tasks (etc.). from today's perspective, it seems like a no-brainer in this context to build in a rich command-line history feature with search, cut, paste, and movement by words for command-line editing, plus filename completion. readline is solving a much harder problem given that it had to do everything through termcap and degrade gracefully on shitty terminals! maybe it's a harder sell when you have to write it all in 8088 assembly, or (more likely) when you've never used a system like that before
(for batch files, it also seems like a no-brainer to implement something like the bourne shell's control structures, and there was less excuse for not doing that, given that they were already aping unix's hierarchical filesystem)
it makes me wonder what kind of obvious improvements on today's computer systems we're missing
- snmx999 1 year agoThere was DOSKEY starting with MS-DOS 5. It could be opened with F7 and the commands could be browsed through with arrow up and down keys.
- kragen 1 year ago
- makr17 1 year agoI haven't worked with sqlplus in forever, and I'm much happier for it. But back in the day we would wrap sqlplus with socat to add readline behaviors.
- dredmorbius 1 year agoLast time I touched Oracle is going on a couple of decades ago. But I did discover at the time a readline wrapper which provided at least a modicum of functionality. Looks as if that's Still A Thing:
- lmz 1 year agoPretty sure sqlplus lets you edit the buffer with "edit". Readline still better though.
- chasil 1 year ago
- akira2501 1 year ago> It's a relief seeing readline pulled in as a dependency for some command line tool
When it isn't just use 'rlwrap.'
> some time and see how awful it is to lose the ability to up-arrow get the last query back, edit it, and send it again.
[A
- singleshot_ 1 year agoWait a minute — when I hit arrow keys in vi and get letters instead, is that because vi is in no-read line mode? I figured this was a termcap thing (for the past twenty nine years while I’ve been a vi user).
Apparently, a pretty incurious one.
- fsckboy 1 year agoi'm a little rusty wrt facts at my fingertips, but broadly speaking (i'm using "you" to mean program author, but that entails sometimes being a program's victim):
when you want a program to get everything the keyboard sends (which means the program will have to handle everything the keyboard sends), your program needs to put your tty into "raw-mode". If you want the operating system to handle things like backspace or left-arrow to correct typos, instead of putting it into raw mode, your program just leaves it with the default in what-came-to-be-called "cooked mode"; cooked mode generally means a line will be sent at a time after ENTER, instead of char by char as keys are pressed (note, this is not the same as half and full duplex, though it is related).
Programs can be linked to use readline to read, while the rest of the program can be written as if the tty is in cooked mode; readline will handle the raw mode. Upon receiving characters typed and an ENT, readline will send cooked lines
If your program is getting char by char in raw mode, you need to realize that some keys don't send single chars, they send a series of chars, generally an "escape sequence", both because the sequence needs to be escaped, and also because the sequences escape with the ESC key-char.
you can get into weird modes where the ESC chars get swallowed but the rest of the key-chars pass through. That's what you are seeing when you see letters get typed but not interpreted as arrow key movements. if your keyboard is persistently screwed up, you can use stty to reset it, or if you are really fancy, set it the way your non-functioning program expects it to be set.
- fsckboy 1 year ago
- singleshot_ 1 year ago
- npsimons 1 year agoForget the up-arrow, C-r is a life-saver for us Emacsers who have to go to CLI for whatever reason.
- globular-toast 1 year agoPlus C-a, C-k etc. This is one of the reasons I'm so glad I learnt Emacs defaults instead of something else like vi. It works in every program that users readline!
- tristan957 1 year agoYou can just use vi keybinds in readline globally via the inputrc file.
- tristan957 1 year ago
- globular-toast 1 year ago
- joezydeco 1 year agoI get a sense of dread when I see readline pulled in as a dependency because now I'm GPL3.
- enriquto 1 year agoI don't understand. Are you afraid of being able to see the source code of the program you are going to use? You are not forced to look at it, if you don't want to.
- joezydeco 1 year agoI've worked on a number of embedded systems for clients that prefer not to allow for user modification of libraries or system code. You know, that TiVo-ization stuff. Many of them are more than happy to comply with GPL2, but have banned GPL3 code from their companies altogether.
My current bane is BlueZ, which used to allow for a compile-time removal of readline but no more.
- efdee 1 year agoThis is about using readline as a dependency in your own software. Because readline is GPL3, your software must also be GPL3.
- cyberax 1 year agoYeah, you don't.
GPLv3 means that you can't use it with the code you write for your job. And there are cases where readline can sneak into the codebase through unintended routes.
- joezydeco 1 year ago
- kstrauser 1 year agoI can't think of a scenario where that would bother me, for personal stuff or at work. It'd be an issue if I wanted to ship a proprietary product using GPLv3 dependencies, but I don't, so it doesn't affect me at all.
- tmountain 1 year agoYeah, that adds a fairly terrible level of inflexibility for sure if you're working on a proprietary product. On a non-commercial level, it causes friction with anything licensed as BSD/MIT/Apache/etc, and that puts a lot of projects out in the cold.
- kstrauser 1 year agoI can't imagine too many cases where readline would get pulled into my proprietary code as a transitive dependency. I mentioned psql above: it's not as though I'd have `#include "psql.h"` in my own project.
What's this friction between readline and other licenses in other Free Software code? Unless I'm writing some software with a non-GPL license and want to include GPLed software in my own that I plan to distribute, it doesn't affect me.
- kstrauser 1 year ago
- enriquto 1 year ago
- saghm 1 year ago
- gumby 1 year ago^U in readline isn't an emacs command (that keystroke does something else in emacs); it's the old teletype protocol for line input.
So if you aren't using readline, ^U deletes everything back to the beginning of the line. Readline preserves that because us pre-readline old farts have it wired into our fingers.
Before display terminals there were just printing terminals: IIRC # deleted a character and @ everything to the beginning of the line. This goes back to Multics and was carried forward in early releases of Unix at Bell Labs.
This is obviously pretty inconvenient when you have a display terminal but I am pretty sure that code remains in the bowels of the BSD TTY IO system at least and can probably be enabled. Maybe it even survived into linux for some compatibility reasons.
Also I WUZ THERE and I think Chet has it backwards on the POSIX controls issue: bfox talked about the TWENEX line input JSYS that had that stuff built in (I believe it was also, perhaps even earlier, in VMS, and maybe TENEX, and surely he had talked to some of those folks too)
- chasil 1 year agoDebian dash is a minimal POSIX shell that also is able to implement "set -o vi" (as suggested by POSIX.2).
http://gondor.apana.org.au/~herbert/dash/
The dash shell doesn't use GNU Readline to implement "set -o vi" but instead uses "libedit":
Debian does not appear to link dash with libedit, so command line editing is disabled.
They should consider doing so, and offering dash as an interactive shell. This would give people fewer bashisms to unlearn when they need to write portable scripts for the POSIX shell.
The dash shell is actually reasonably pleasant for interactive use when compiled with libedit.
- andrewshadura 1 year ago"They" have considered it and tried it, but had to revert the change. Dash is in Debian primarily for scripts, not for interactive usage. If you want to use dash with libedit, you have to compile it yourself, unfortunately.
- 1vuio0pswjnm7 1 year ago"The dash shell is actually reasonably pleasant for interactive use when compiled with libedit."
For me it's the preferred interactive shell. When compiling dash with libedit, I edit dash source to enable tabcomplete. Then it feels more like NetBSD.
I've been running an experiment using busybox bash instead of dash as both interactive and scripting shell; have discovered numerous busybox idiosyncracies as a result. One thing I like about busybox bash is it's command history search: Ctrl-r. A bit faster than libedit.
NB. "set -o vi" can be abbreviated to "set -V"
- 1vuio0pswjnm7 1 year agobusybox "ash" is littered with "bash-like" features. Searching command history using Ctrl-R is just one of many. IMO, it has enough changes from NetBSD sh and Debian sh that it is neither ash nor bash. Regardless, I should have referred to it as "busybox ash". Apologies for the inadvertence.
busybox includes a config option to include a "bash" applet name that points to "ash"; typing "busybox" one will then see "bash" listed as an applet, but is the same shell
Sometimes when compiling software, authors insist on using bash scripts at compile-time rather than sh scripts. Trying to use busybox ash to run these scripts will fail because there is no applet called "bash". There might be another workaround but I find it useful to compile busybox to include a "bash" applet name.
- 1vuio0pswjnm7 1 year agoAnother nice thing about busybox ash is that it's easy to recall and edit previous commands by editing the .ash_history file.
Normally I would do this in NetBSD sh using the builtin "fc"; dash excludes the fc builtin.
- chasil 1 year agoI understand that busybox bash is specific to the windows port.
- 1vuio0pswjnm7 1 year ago
- andrewshadura 1 year ago
- sodapopcan 1 year agoThis is cool, I didn't actually know you could configure Readline so the title is apt for me :D
Much like in the article I'm also a Vim user who excited to try Vim mode at the command line and I almost instantly hated it. I suppose it's almost required to mention tpope's rsi.vim[0] which gives you Readline bindings in insert and command modes. I've adopted Readline everywhere in my OS except in Vim normal mode which I believe is not too uncommon for many folks.
- loulouxiv 1 year agoDid not know of this plugin but my life changed when I realized that pressing ALT+<key> registers as pressing Esc then pressing the key. Therefore in insert mode I just do ALT+I to go to start of line, ALT+A to go to end of line, ALT+o / ALT+O are also useful
- tux1968 1 year agoTpope's naming of those bindings is meant as a bit of a joke, maybe? I've always felt that Emacs bindings was leading to Repetitive Strain Injury; and really appreciate being able to use Vim bindings, even at the shell prompt.
- sham1 1 year agoPeople do like to talk about emacs bindings causing RSI, usually to rib on the editor and to keep the tradition of the editor wars going. However, there really isn't all that much evidence for it, is there?
Of course it's often in jest and somewhat famously the plural of anecdote is data, but it would be nice to know if there actually is something to the RSI. Ergonomics is complicated enough as-is.
- sodapopcan 1 year agoMy only evidence is that my RSI got better once I started using Vim full time. Of course, Vim forced me to learn to touch-type and I also never used Emacs, but I'm just going to go ahead and attribute the cured RSI 100% to Vim and assume every other editor causes it. That's my "research" tells me, at least! :D :D ;)
- sodapopcan 1 year ago
- ramses0 1 year agotpope has $DIETY-tier naming skills: `fuGITive`, `scriptEASE`, `PATHoGEN`
- sodapopcan 1 year agoWow, I never put scriptease together, I figured he was purely being lude, lol. I feel a bit dumb but thanks for pointing it out!
- ldmosquera 1 year agoYou left the very best out: dadbod.vim (a DB helper)
- sodapopcan 1 year ago
- sodapopcan 1 year agoThe name is certainly a joke but the plugin is not. There is certainly nothing wrong with using Vim bindings on the command line if you're into it! 'tis the beauty of configuration.
- sham1 1 year ago
- loulouxiv 1 year ago
- gray_-_wolf 1 year ago> Also, without some sort of indicator, Vim’s modal design is awkward here—it’s very easy to forget which mode you’re in.
That is why I have this in inputrc:
set editing-mode vi
set show-mode-in-prompt on
set vi-ins-mode-string +
set vi-cmd-mode-string :
- sre2 1 year agoYou could easily improve upon that. For example the following will change the cursor to a block in emacs mode, an underline in vi-command and a line in vi-insert in most terminals.
The worst thing about the bash config of readline is that bash disables the key combinations for going from emacs-mode to vi-mode (ctrl-alt-j) and back (ctrl-e). They work everywhere else (where I've checked anyways) and you can't turn it on again in inputrc, you have to bind it in your .bashrc, all that because the bash developers think it would be too confusing to have it work the same in bash as anywhere else were you have readline support.set show-mode-in-prompt on set emacs-mode-string \1\e[1 q\2 set vi-cmd-mode-string \1\e[3 q\2 set vi-ins-mode-string \1\e[5 q\2
- tristan957 1 year agoWhat's the bind incantation in the bashrc you recommend? Here is what I tried:
The second keybind does not seem to work. If I just make it control-j, it works. For some reason the meta is throwing it off.bind -m vi-command 'Control-e: emacs-editing-mode' bind -m emacs 'M-C-j: vi-editing-mode'
- sre2 1 year agoYou are looking for
and possibly addingbind -m emacs-meta '"\C-j": vi-editing-mode'
bind -m vi-insert '"\C-e": emacs-editing-mode'
- sre2 1 year ago
- tristan957 1 year ago
- sre2 1 year ago
- jlv2 1 year ago"Tens of thousands of people probably use it every day without thinking about it."
Probably tens of millions at this point.
- klibertp 1 year agoOne important characteristic of this `readline(const char*)` call is that it blocks. So, if you're trying to write a REPL for a language that uses green threads for concurrency - I'm looking at you, GNU Smalltalk - then DON'T. At least not from the main thread.
- mklein994 1 year ago> Also, without some sort of indicator, Vim’s modal design is awkward here—it’s very easy to forget which mode you’re in.
With `bash`, you can show which mode you're in by putting this in your `~/.inputrc`:
It makes your prompt look like this:show-mode-in-prompt on
Customize these with `emacs-mode-string`, `vi-ins-mode-string`, and `vi-cmd-mode-string`.[foo@bar ~]$ # before turning it on @[foo@bar ~]$ # after @[foo@bar ~]$ set -o vi (ins)[foo@bar ~]$ # and after I press esc: (cmd)[foo@bar ~]$
- bbminner 1 year agoBash uses readline, right? So
> Tens of thousands of people probably use it every day without thinking about it.
seems like an understatement.
- globular-toast 1 year ago> One thing I’ve done is reconfigured Ctrl-K. Normally it deletes from the cursor to the end of the line, but I rarely do that.
I would recommend against this. I delete from the cursor to the end of the line all the time. Maybe more in Emacs than readline, but still
You can already delete the whole line by issuing C-a then C-k. I also do this all the time and that key combo is as easy for me to type as any two letter word.
Remapping C-k means you now have two ways to kill the whole line and no way to kill from the cursor.
But worse: you're teaching yourself a keyboard setup that only you use. You'll be lost on somebody else's computer, or any time you don't have your config installed. The standard readline bindings turn up in sometimes surprising places and it's a joy when you realise you're already trained to use some system or software you've never used before.
I'm surprised the article doesn't also mention C-y. After you've C-k killed something it goes on to the "kill ring". Press C-y to bring it back! (You can bring more than the most recent thing back, but you now have the key words to look this up yourself).
- oska 1 year agoLovely opening paragraph :
> I sometimes think of my computer as a very large house. I visit this house every day and know most of the rooms on the ground floor, but there are bedrooms I’ve never been in, closets I haven’t opened, nooks and crannies that I’ve never explored. I feel compelled to learn more about my computer the same way anyone would feel compelled to see a room they had never visited in their own home.
- strbean 1 year agoThis is nostalgic. For a Systems Programming course, I had the following assignment:
- Implement readline(3)
- If you have any questions, see the man page.
- Extra credit: implement all GNU extensions.
- 20after4 1 year agoWhat a great assignment. I would have loved that class.
- strbean 11 months agoA cool way to structure the class, but hurt by the fact that the professor steadfastly refused to provide anything beyond the man pages. Even the lectures consisted of him putting a man page up on the projector and reading it aloud, verbatim.
- strbean 11 months ago
- 20after4 1 year ago
- meribold 1 year agoTo make Less (the pager program) behave a bit more as if it used Readline (it doesn't), one can create a `~/.config/lesskey` file with these contents:
I think a relatively recent version of Less is required.#line-edit ^A home ^E end ^F right ^B left ^P up ^N down ^D delete ^W word-backspace \ed word-delete \ef word-right
- kickaha 1 year agoHoly GOD all these years of wasting time on HN have finally paid off!
THANK YOU FOR SHARING THIS
- kickaha 1 year ago
- jeffrallen 1 year agoCtrl-k kills the rest of the line. Ctrl-u kills the entire line.
Ctrl-y yanks stuff back in from your kill ring. Esc-y will then replace the stuff with the previous item in the kill ring.
Ctrl-arrows moves a word at a time.
Ctrl-r starts a reverse interactive search through the history. Use any editing key, like ctrl-e to start working on the current search result.
- akira2501 1 year agoCtrl-c aborts input and leaves the previous partially edited line visible.
Ctrl-g cancels Ctrl-r searches. So if you want to search and then search again you can clear the history position with Ctrl-g.
Ctrl-s moves forward if you went too far with Ctrl-r.
Ctrl-r twice in a row retrieves the previous search.
Alt-u upper cases. Alt-l lower cases. Alt-c capitalizes. From current position to end of word.
- akira2501 1 year ago
- uncletaco 1 year agoOne thing trying to work with Guix over the last five years taught me is how much I take for granted all the little things that come packaged extra. I was using guix for about a month before I learned that readline was the package that allowed me to do a lot of the extra commands like ctrl-c etc.
- meribold 1 year agoSome more good ideas for Readline configuration: https://www.topbug.net/blog/2017/07/31/inputrc-for-humans/
- usr1106 1 year agoThe article feels incomplete for not not mentioning the bash built-in called bind. It allows you to work with the reeadline bindings.
I use Ctrl-R a lot to find previous commands from my shell history. Often I have to press Ctrl-R several or even many times to find the right one. And then it happens that I overshoot and would like to change the search direction. Unfortunately forward-search-history is on Ctrl-S, which is overloaded by flow control. Occasionally I use flow control, so I cannot remove that. What solution are others using to get forward-search-history?
- galenelias 1 year agoShout-out to the clink project, which brings a modern shell experience (including Readline) to Windows' cmd.exe. This is the most advanced shell I have across Mac/Linux/Windows, which is always a bit surprising. It's extremely extensible and has some pretty incredible functionality written for it (also by the maintainer).
- chasil 1 year agoI just use the busybox port to Windows.
- chasil 1 year ago
- ramses0 1 year agoRemiss for not mentioning "rlwrap": https://github.com/hanslub42/rlwrap
...basically "readline in a can" that you can use to improve text input of other programs.
I forget if it was RMS or ESR that really wanted to hold "readline" away from corporations, so it's licensed as GPLv3 (not v2), and he explicitly wanted it to _not_ be LGPL (ie: embeddable).
My crazy readline/bash tip is `ESC, .` (or maybe `alt+.`, I'm not 100% sure, random search result here: https://gist.github.com/tuxfight3r/60051ac67c5f0445efee ). Basically it up-arrows through the last "word" of previous commands, adding it to the current command.
Example:
It's crucial in that it reduces the number of keystrokes, and avoids typing errors completely, as you're "recalling" something rather than re-typing.mkdir foo cd `esc, .` => cd foo vim bar.txt cp `esc, .` baz.txt => cp bar.txt baz.txt
I'm also in the same boat as the author in that `set -o vi` doesn't quite do it for me (although I consider myself an expert in vi). What I tend to do instead is:
...basically it invokes: `$EDITOR "$( history | tail -1 )"` and whatever you save/quit will get executed as a command.C-a # <cr> => go to the beginning of the line and insert a comment char fc => "fix command", see "help fc" (it's a built-in)
This lets me intentionally "damage" a command, but then get into `vim` to "fix it up" (eg: `dw, cw, df/, etc...`). Remove the comment from the beginning of the line to execute it, or keep it there to take the command back "out" of `vim` so you can keep building it up.
- wild_egg 1 year agoI've always used !$ to get the last word of the previous command like so:
I suppose the advantage of `ESC, .` is universality since it'd work inside any readline prompt? Not sure how frequently I actually need to do that outside of bash but going to keep it back of mind in case I do, thanksmkdir -p foo/bar cd !$ # => cd foo/bar
- ramses0 1 year agoI like the interactive nature of esc-., you can keep "up arrowing", to a value a few commands ago and crucially: edit the value. (add/remove `tgz`, etc)
- ramses0 1 year ago
- loulouxiv 1 year agoC-x C-e opens an editor with the currently edited command
- fragmede 1 year ago`alt .` :)
- wild_egg 1 year ago
- TZubiri 1 year agoSome years ago I sent a bug report to the email listed at the end of a man page.
I don't recall what the bug was, I also don't recall why the video I sent showcasing the bug had my national anthem in the background. But it sparked a nice bug report exchange.
That he is doing this for no pay and for the passion of providing software to users all around the world fits.
- geophile 1 year agoI was writing a command-line tool in Python, and wanted bash-like line editing capabilities. And then I realized that there was a Python wrapper for readline. Problem solved!
- BeetleB 1 year agoReadline is good, but once I started using the xonsh shell, and prompt_toolkit, going back to Readline always feels a bit lacking.
- anovikov 1 year agoGreat thing, but it is GPL... there is libedit that's LGPL and while isn't a complete replacement, is good enough.
- godelski 1 year ago
I just want to remind everyone of the xz hack. The lesson here is that a few people maintain projects that are critical to our infrastructure. You may be familiar with the XKCD comic[0], but this makes it look like the unpaid single/few maintainer critical projects are rare.> Ramey has now worked on Bash and Readline for well over a decade. He has never once been compensated for his work
These people are generally unpaid and that has big ramifications. Sure, it makes them susceptible to bribes and more prone to hostile takeovers (however you view xz), but there's more. It means these works are simply a work of passion, and they are working on them in their spare time. We all know here that that time is less and has lower priority than our work time. So you're more likely to be rushed and make mistakes, or not be able to fix things fast enough, and so on. Is this really the way we want this infrastructure to be maintained? Startups have more stability than this and are more likely to pass the "CEO hit by a bus" rule[1]. Not to mention the difficulties of transitioning when the dev wants to retire or move onto something else. This does lead to issues, and while we've solved them in the past, that doesn't mean we can't do better.
Surely they deserve some compensation. We have 8 companies which are worth over a trillion dollars and certainly all 8 use readline. Are you telling me that these companies can't collectively kick back $200k/yr. That's literally what Elon makes in 10 minutes if he gets 5% on his wealth. I find it hard to believe we don't have enough money to fund possibly thousands of these projects (if there are that many, but there are likely that many people). It only takes Ballmer 16 minutes and there are 20 people who can do it in 30 minutes or less (~50 for 1hr). Collectively the top 10 make 230 million per day for doing nothing. I think we have the money. (remember, we're talking about products that these companies are using. This isn't just a "pure donation," as these things have clear market value and the loss of the maintenance will result in these companies also losing money)
At the least, I'd like to remind everyone that the company you work for likely offers some matching donation. If you're at one of the big tech, they do.
[1] If your CEO, or any single specific employee, is hit by a bus and can no longer work, does the entire company also collapse?
- 1vuio0pswjnm7 1 year agoIME
always feels faster thansocat readline prog
rlwrap prog
- apitman 1 year agoThis is way off topic but 2 hours ago I was trying to figure out how to read a single line from stdio using Rust/tokio and failed to figure it out in a reasonable time. It was infuriating.
- ComputerGuru 1 year ago
And I just looked it up and it's right there in the docs, too: https://doc.rust-lang.org/std/io/struct.Stdin.htmllet mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap();
You basically shouldn't use `tokio::io::stdin()` for what you want, as is documented at https://docs.rs/tokio/latest/tokio/io/fn.stdin.html
> For interactive uses, it is recommended to spawn a thread dedicated to user input and use blocking IO directly in that thread.
So the code under tokio would be
let line = rt.spawn_blocking(|| { use std::io::stdin; let mut buffer = String::new(); stdin().read_line(&mut buffer).unwrap() }).await.unwrap();
- apitman 1 year agoYeah std::io is what I ended up using, but it felt like I might be doing something wrong. Wasn't sure if using blocking IO would mess with tokio. Your answer seems to indicate that intuition was correct, and I should be wrapping it in spawn_blocking. That all makes sense, it would just be nice if your comment was at the top of the google search results.
- apitman 1 year ago
- kstrauser 1 year agoI could stand to hear more about this. What problem were you running into?
- apitman 1 year agoBasically googling "tokio read line" didn't lead me to uncle's solution.
- apitman 1 year ago
- ComputerGuru 1 year ago
- hollerith 1 year agoThat's nice, but if GNU readline disappeared from my Linux install I probably wouldn't notice.