200 points · by tambourine_man · 7y ago · 127 comments
[1] https://github.com/ryanoasis/nerd-fonts
[2] https://github.com/ryanoasis/nerd-fonts/wiki/Codepoint-Confl...
Anyway, one nice thing about TrueType/OpenType fonts is that the vector representation is extremely well compressed. SVG or similar would be an efficiency loss. In this light, fonts are actually a fairly decent and practical way to represent vector symbols that will be cached and reused. Maybe a minimal practical solution might be to add an ANSI extension that requests an appropriate font for a particular area of the screen, perhaps with a URL from which a specific webfont can be fetched.
stty saneI agree that an external resource is a lot of hurdles. What I had in mind while writing the reply was a stripped-down version of TrueType, with only a single `glyf` table allowed (probably with a minimal version of the `head` table as well). Judging from how icon fonts are used today, this might even be possible without a persistent font state.
Agreed, and I don't understand why most of the things still done in the Unix terminal have not transitioned to newer, less hacky environments.
I managed to replace the vast majority of the things I was using the terminal for with uses of about 400 lines of Emacs Lisp code that I wrote about 5 years ago.
A large fraction of my uses of the terminal since then have been for the purpose of my getting my Emacs environment and my data files installed on a fresh install of my OS and for recovering from those times when I inadvertently introduced a bug into my Emacs environment that my regression tests did not catch.
The 400 lines of Emacs Lisp code submits a string I typed to bash with the -c flag then asynchronously (i.e., without blocking Emacs's UI) waits for output from the bash process. I also added a way for the user to arrange for a bell to ring when the process finishes. Notably, there is no provision for the user to cause anything to be sent to the process's stdin after the process is started, which allows the 400 lines of code to use a pipe instead of a pty (which is relevant to this comment thread because if OSes didn't need to support the pty abstraction, they could be significantly simpler). In the rare case when I want to send a string to the stdin of some process I use the shell to set things up:
echo "here is the string" | some process
That whole command line becomes one argument to a call to bash. The 400 lines of code I wrote cannot be used to interact with a REPL. E.g., if you use my 400 lines of code to run "python" by itself as a command line, the python process waits for user input, which will never come because there is no way to write to the python process's stdin.The closest analog in standard Gnu Emacs to the 400 lines I wrote is "shell mode" (shell.el) which consists of about 3 or 4 thousand lines of Emacs Lisp code. My code re-uses shell mode's code for interpreting (ignoring in my case) the escape sequences for ANSI color and for interpreting the escape sequences for "carriage control", but (like shell mode) does not handle the escape sequences for cursor addressing. IIRC the main reason I was dissatisfied with shell mode was that it contains hacky code to keep the bash process's "opinion" on what the current working directory is in sync with the shell mode buffer's "opinion" on what it is. In contrast, in my code, the buffer's "opinion" is the only one that matters (because every command line is processed by a fresh bash process on that bash process inherits its current working directory from the Emacs process when it is created).
If I ever were to start to need to issue a great many command lines on a variety of remote Unix servers, I would probably take the time to write a replacement for ssh along lines similar to what I just described.
It would not be a trivial amount of work to build this since, to take good advantage of the UI capabilities, you'd need an entire new CLI OS - something to replace GNU Core Utilities. I haven't been sure where to start since the choice of programming language or expression language will significantly affect the overall experience.
The only more or less widely used solutions are iTerms image support (PNG images, no vector), or Sixel (xterm and some other exotic ones).
There is also ReGIS (https://en.wikipedia.org/wiki/ReGIS), which is a vector format, which might be supported by xterm (not sure).
[1] https://www.unicode.org/L2/L2019/19068-powerline-syms.pdf
This usually works not by having fonts define emojis (most don't) - it's just that systems reach in and render emojis from a dedicated emoji-defining font when they encounter them. So it's not like the world is full of fonts that define 'standard emojis' or funky powerline symbols.
For raster images there are sixels, and for vector there are the tektronix codes. These are standard in xterm since forever.
Of course, they could be modernized, using real raster pixels and something like a subset of svg. I guess before standarization it would be better to have a reference implementation included in a major standard terminal.
A standard xterm supports vt340 if you start it with the option "-ti vt340" which supports ReGIS as well.
https://github.com/saitoha/libsixel
By high-resolution I mean you can display JPEGs using sixels. You can run OpenGL programs using sixels.
Otherwise, ripgrep's support for .gitignore should be substantially better than what's in ag. You can use .rgignore just like .agignore. Both ripgrep and ag also support .ignore. These can override whatever is in your .gitignore.
See the guide for more details: https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#a...
> Performance difference is not that much of a dealbreaker in practice
This is true for smallish inputs. But the difference should become larger for bigger inputs. Hell, sometimes ag just refuses to search inputs that are too big. e.g., For a ~9.5GB file:
$ time rg '\w+\s+Sherlock Holmes' OpenSubtitles2016.raw.en -c
3003
real 1.608
user 1.105
sys 0.496
maxmem 9473 MB
faults 0
$ time ag '\w+\s+Sherlock Holmes' OpenSubtitles2016.raw.en -c
ERR: Skipping OpenSubtitles2016.raw.en: pcre_exec() can't handle files larger than 2147483647 bytes.
real 0.016
user 0.004
sys 0.011
maxmem 6 MB
faults 0 $ echo foofoo | rg foo --vimgrep
<stdin>:1:1:foofoo
<stdin>:1:4:foofoo
What you want is probably `--no-heading`. You can add it to a config file or an alias if you always want it enabled: https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#c...Show results with every match on its own line, including line numbers and column numbers. With this option, a line with more than one match will be printed more than once.
Now I feel like all my hard earned cli-fu is a lie.
Anyways, Id been away from *nix for a few years at the time, so I was a bit rusty and soon felt like a moron and closed the bug once I realized my error.
> Now I feel like all my hard earned cli-fu is a lie.
fd is also a lie. If you want a decent interface to find just use "find | grep ..."
I'm sure you already know this, but sed is meant to provide the features that ed does, so sd is quite a bit more limited. Still, I can see how this can be useful, as most invocations of sed end up only really using a handful of its features.
Although personally, I've only really used sed for find & replace so sd solved my gripes with sed perfectly.
I guess my brain just refuses to remember these for some reason.
If you feel that there is anything we could to to improve fd's UX, it would be great if you could share it on GitHub: https://github.com/sharkdp/fd
> Why separating the extension from the filename? Is this a default
It does not need to be! You can just also just use "fd README.md". Admittedly, the "." will actually search for any character (regex), so if you want to be precise, you need to escape it.
However, here's my reasoning for the first of your questions, as a happy fd user who switched from GNU find. Maybe it can give you insight into why the UX is designed as it is.
The extension is distinguished from the filename because it's a common use case (-e jpg less keystrokes than -iname '*.jpg'), it's semantically separate from the filename (IMO) and therefore should not be treated as part of it. And unlike filenames, extensions most often do not need to be pattern matched. If you want to match multiple extensions, just repeat the -e flag e.g. -e jpg -e png.
Would love to see this resolved, cause it seems rather nice otherwise.
So please drop the dismissive patronizing tone.
It’s obviously not a matter of needing, but of aesthetics and usability, and that’s very much a valid pursuit.
I probably run ls a few dozen times a day, but it's usually just to answer "what did I call that file again?" or "did I remember to copy that over?"
I can't imagine a scenario where I'd require too many extra visual cues. I use color ls, mostly because I find the optional symbols like '/' to be distracting, and differentiating files and directories via color is about all I care about.
There's overhead in becoming too attached to non-standard tools: you have to go out of your way to install them, your muscle memory needs retraining, etc.
Most importantly, tools like this break a bunch of core command line standards, like doing one thing and doing it well, and producing clean output that can be pipeline-filtered with all the other Unix standards.
Playing the "doing one thing" card when it comes to ls is rather risky, as ls, with its options for doing things like sorting its output, is one of the favourite examples that people point to of tools that do not adhere to this philosophy in practice.
* https://news.ycombinator.com/item?id=4023265
* https://news.ycombinator.com/item?id=9673975
* https://news.ycombinator.com/item?id=8484718
... and so on.
https://github.com/alebcay/awesome-shell
Only for rust but not a bad list I think.
https://lib.rs/command-line-utilities
Some blog post introducing cli tools.
1. People predict Rust will be more popular in the future, so they're trying to learn/master the language by practicing it.
2. People think speed and memory safety are important guarantees for unix programs.
3. People are testing whether Rust deserves the fame it has
I don't think any of the typical unix tools ever segfaulted on me in the last 15 years I use Linux.
Something as simple as `ls` is probably so small and battle tested that it's not an issue, but if you're writing an all-new, not-battle-tested tool, why wouldn't you want stronger guarantees? The new tool is being written for the features, but it's not fun to write vulnerabilities into something that should be simple and "just work."
Languages like Go and Ruby are also mostly memory safe, so those are generally fine picks here too, but every language has trade offs. In this case, the author clearly cares about performance, which Ruby does not care about.
Rust also has a built-in testing harness, which is a lot more convenient IMHO than using whatever C testing framework you might have a predisposition towards.
Rust is great in this sense because you don't have to think about those issues.
That said, I'd pick rust over C for most projects simply because it's a nicer language to write IMHO. It feels like a modern high-level language with things like iterators, traits, etc, and it has a great package manager too. In comparison, I find writing C to be a huge chore, especially if you're doing much string processing
That library is used by most(?) rust cli tools, so they all have a similar feel. In addition, there is a library built on top of clap called struct-opt that makes bringing up a new cli exceedingly easy: https://docs.rs/structopt/0.2.15/structopt/
Seriously, checkout struct-opts page even if you don't know any rust. I think their demonstration on the front page summarizes a lot of things I like about idiomatic rust.
- Compiled so easy to distribute compared to Python, JS, etc - Cargo makes it easy to pull in libraries compared to C/C++ - Smart people made some great libraries that make it trivial to get performance and/or a nice UX. e.g. Everything in ripgrep is available for reuse, down to how it walks the filesystem.
A modern replacement for ls, written in Rust. https://the.exa.website/
ls with coloring and icons https://github.com/Electrux/ls_extended
However it's written in our lord and savior RUST and has lots of colors so this shit is definitely "next gen."
0: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls...
So you're using this as an opportunity to bash an entire language ecosystem? The merits of this project have no bearing on Rust or its adoption.
I think the parent was bashing the attendant hype and the resulting reinventions but worse.
There was a blog I read about the Rust Zealot Brigade (or similar name) that would reliably descend on any HN conversation.
1. It’s written in the author’s preferred language