Command Line Tools to Break Your Dependence on the GUI
putorius.net
putorius.net
Also, bc is especially terrible. Nobody who is already "dependent on the GUI" is going to want to know about scale= and all that. Better to use Python or even bash (echo $((123+456)) etc)
I'm confused. Manipulating files and running programs is a given, isn't it? You mean ls/cp/mv/rm-style? And running programs is... type in the name of the program (if in $PATH) or its path (if not) and press enter. Why would anyone bother blogging about that?
"Awful" was a mean description of this article. I'll fix it (edit: comment, not fix).
touch file
if you need an empty file (also prevents accidental truncation).(Ok, it’s a bit cheating, sort of text/GUI, but makes file manipulation so easy on console)
In other words, things a typical GUI file manager can do easily.
ls?
> what data the files represent
ls, file
> which programs would be useful to operate on the files?
I guess I assume that people know this kind of thing, but xdg-open is fine.
I just meant that IMO it's more productive to get familiar with the shell and demonstrate powerful shell alternatives than learning a handful of situation-specific CLI alternatives. Getting to know things like shell expansions, using ipython (or whatever) for adhoc data crunching, the "jq" command, sup/mutt/whatever and so on will make someone a much better CLI wrangler (and less dependent on GUI tools) than knowing you can Google from the command line.
I had a twinge of hope that this might have been more of an introduction to using the terminal effectively on Linux for diagnoses.
I'm new to Linux, and every time I have an issue and find a thread addressing it, they ask for me to run a whole bunch of commands and paste a bunch of logs. I'm happy to do that, don't get me wrong, but I rarely have the faintest idea of what it is that I'm typing in.
I try to get novices interested in the shell via youtube-dl, which is very useful and has no good GUI counterpart. However, for a lot of people, downloading copies of video are just not an everyday task like checking the weather or dictionary.
Also I would say: don’t try to force it. People write a lot about ricing their Gentoo installs, which tiling window managers use the least RAM and which plugins they use with Neovim. This makes using the terminal effectively seem like a big thing.
But the terminal is exactly not that — all proxies are removed and you just use it for what you want to do, nothing more. Just start by using grep on a text file instead of opening that text file up in your editor.
By default, that's tied to 'man', which lets you look up a particular command in the system manpages. Swap that to dict for text files (say, filetype markdown or HTML), and you've now got a dictionary lookup for any given word. Not sure of spelling or meaning? Position cursor on word and hit 'K', and you'll get the word's definition, or a match of near-spellings.
The dict database can also be extended to other datasets -- anything with a keyword-result relationship. On Debian, this includes the US Census "Tiger" files (thanks to Bruce Perens for buying a copy and sharing them to the project), which lets you look up any specific city or place name in the United States.
You can specify the dictionary you want to use on the commandline, or write a shell alias or function to query a specific database, say:
dictzip () { /usr/bin/dict -d gaz2k-zips "$*" | ${PAGER:-less}; }
dictplace () { /usr/bin/dict -d gaz2k-places "$*" | ${PAGER:-less}; }
Which allows you to query ZIP Codes or place names without otherwise mentioning the dictionary on the commandline.There are numerous other query tools bundled together in tools such as surfraw(1) (https://packages.debian.org/buster/surfraw), with 123 separate query targets.
Or you can write your own. I've got a wrapper around the NOAA's weather six-day forecast page which dumps a text-formatted version of just the forecast text (a lot of ugly sed and awk). Having to write programmes to remove the text other programmes lard onto a simple data request is Where We Are Now in Today's WWW.
Or a lookup for the Online Etymological Dictionary:
etym () { \w3m -T text/html "https://www.etymonline.com/word/${1}"; }
(w3m is escaped '\' to byapass the alias I've defined, 'alias w3m="w3m -B"', which defaults to opening my bookmarks file if no argument is given.)Learning what you're typing, and what it does, and what the underlying logic are, is much of the fun.
Usually when the internet says "Run these commands", they either don't tell you what they do, or tell you to just check `man`. The problem is that man pages can be super long, can have a somewhat intimidating syntax, and 1,000 flags that arent your flag. Running `tldr program_name` gives you a way simpler manual with common flags and actual examples.
I suggest checking out Like Smith's beautifully assembled video guides, whom I think has done a lot for newbies by releasing comprehensible content while minimising the whole RTFM attitude that kept newbies away from the terminal.
But yes, also RTFM.
Depends on your job. For certain jobs is 10x more useful than most programs you use every day...
https://github.com/jorgebastida/awslogs
Which allows you to stream Cloudwatch logs via a command like:
awslogs get <log group name> ALL --watch
which is cool because you can just specify the log group and get all streams without having to dig around for the specific stream in the AWS console.There's a python based command line HN client (https://github.com/donnemartin/haxor-news) that's nice, although I think the dependencies need updating (I get various conflicts if I try to install other packages in the same venv).
For twitter, rainbowstream is nice:
Isn't there a word for that ? I'm thinking of "several". That is what I learned in school (not a native english speaker )
It's more like saying "I love my dependence on images, else I would still be stuck using text". Well, text can be more information-dense and efficient than an image or a movie. And similarly, a CLI can be more efficient than a GUI. Depends on the application.
And if the "MS DOS" reference is about release time, well, there are CLI tools that were built far more recently, and are much more modern than many GUI tools people use.
git clone git://github.com/tmux/tmux
git switch sixel
git checkout b1904c9b8db514133d3372aac13b2ff0b2093cc3
This will give you the "placeholder" box for sixels in terminals that do not support sixel (but you should use mlterm on Linux or mintty on Windows)
The upcoming feature is to replace this placeholder box by unicode art for the sixels, cf https://github.com/tmux/tmux/issues/1613 for the current discussion.
Then you will be able to break your dependency on the GUI just by using w3m and your favorites sites, whether your terminal supports sixel or not (but it should, it's just better!)
apt-get install libsixel1-bin
w3m -sixel -o display_image=1 google.com
Cf https://apple.stackexchange.com/questions/244930/how-do-i-vi...
There are other apps with integrated sixel support like mikkuter for twitter, gnuplot (there was https://github.com/csdvrx/sixel-gnuplot , but now the sixel backend is compiled by default in the official gnuplot-nox starting from debian-10)
At the moment, I'm working on a mutt hack rendering outlook emails with all their included thingies (images etc) into sixels.
If someone is looking for an idea, it'd be great to have a IRC client that replaces URL containing pictures by their sixels renditions, a bit like what lsix does ( https://github.com/hackerb9/lsix )
Many important people are there, e.g. the Tmux maintainer/developer Nicholas Marriott, the Mintty developer, some Xterm.js developer, and others.
Anything that can already support sixels won't be too hard to change to support this new standard, unless it doesn't use pixels -- though it would be neat if this standard was vector based, like ReGIS: https://en.wikipedia.org/wiki/ReGIS - I want SVG in my terminal :-)
For now, sixels already work reliably for most of the things I do. So now, I concentrate on the applications, to make sure most of my workflow can be console based.
Human hands can move very fast, faster than we can assemble cogent thoughts thanks to muscle memory (and other things that I'm sure I'm not aware of). I don't know if this is a universal thing, but I like it when I don't have to think about how to get something done. I consciously picture the end goal in my mind, and my hands just do.
Of course, I'm a sloppy typist, and still relatively unrehearsed when it comes to working with Vim and friends. But I've been most of the standard GNU applications long enough to realize that my brain no longer directs my hands to interact with the keyboard for frequent simple tasks (generate a line plot for this two column CSV, use awk to get the penultimate column of this file, hash files in a directory to remove duplicates, open HN in a browser...).
I'm also a big sucker for working with programs that compose well with other programs. If I had all the time and money in the world, I'd love to have more GUI apps that explored GUI/CLI interop better. I think one example many developers can comment on is how nice it is when you can combine CLI git commands with git in your code editor. Sometimes, it's just easier to resolve ugly merge conflicts with a GUI. Or there's a really weird command that doesn't exist in your GUI so you need to type it out on the commandline.
There's definitely a lot more work to be done in this domain and I'm excited to see how software/OS/library developers explore this in years to come.
I think that is very different than an app with good keyboard shortcuts btw which is why, for example, despite many editors having great keyboard shortcuts I keep going back to vim. So I’m Making basic apps that are intended to be used entirely with a keyboard and just happen to support mouse input too.
I realize this doesn’t work well for everything but my todo app and my note taking app should work great at least.
calc () { awk "BEGIN { print "$*" }" }
$ calc "2^16"
65536
$ calc "2*16"
32
$ calc "2+16"
18 $ units -t "sqrt(3^2 + 4^2)"
5
$ units -t "forty rods per hogshead" "miles per usgallon"
0.0019825576
$ units -t "32GB / (1MB/s)" "hours; minutes"
8;53.333333 $ bc -l <<< 2^16
65536
$ bc -l <<< 2*16
32
$ bc -l <<< 2+16
18https://github.com/draperunner/cutters
Which enables you to run:
$ npx cutters | grep Oslo | head -3
to get queue times in Oslo. Made by a colleague of mine.curl -s https://www.cutters.no/api/salons | jq '.data[] | select(.location.key == "oslo") | .details.estimatedWait /= 60000 | {name: .name, wait: .details.estimatedWait, serving: .details.numberOfServing, waiting: .details.numberOfWaiting}'
1/3
0
Whereas ghci, or your language's REPL, will likely do better: > 1/3
0.3333333333333333 % bc
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
scale=10
1/3
.3333333333 scale=INTEGER
for some reasonable INTEGER, say, 6, to your ~/.bc file (you need to also export BC_ENV_ARGS=~/.bc), or alias bc to bc -l). After having gp-pari fail after a brew upgrade I started using bc instead and have been relatively happy so far (although I miss isprime and factors which I used sparingly)I'd like to note that no manual at all is needed to understand a basic menu structure or a GUI system with consistently used widgets.
I've looked around for a freely-available source of raw stock quote data without success (though not invested too much time in it). I've written my own wrapper around Yahoo's stock quotes page (https://finance.yahoo.com/) which strips off everything but the prices themselves (see sample output: https://pastebin.com/gR2j3zB3)
However that's not something which will query for a specified portfolio.
It does feed xrootconsole nicely though.
More seriously, this doesn't seem to be linux as much as it is bash and a handful of commonly found on linux tools - all of which you can now run on windows anyway.
Windows users: install bash and follow along.
"I think you'll find," he interrupts me, like he's done to most of the other people asking questions "that it's actually GNU/Linux" and then fixes me with a look usually reserved for telling an adult that yes, they really have just soiled themselves.
"Actually," I took great joy in responding, "I'm running Mr Torvalds' kernel with a BSD userland, so really, I'm pretty sure I'll find it's not."
We haven't stayed in touch since.
When I need something, I use pacman.
Line endings can become an issue, as can the various BOM characters.