So the "Terms of Service & Privacy" link doesn't work, and apparently it's a paid subscription service but you don't find that out until you've signed up and tried activating an API key?
I'm sure these are just oversights but it leaves a very bad taste in my mouth!
I was so happy when I discovered this. As a UNIX and Linux user for my entire career I was so surprised that something built into every Cisco, Juniper, Arista etc etc network device wasn't built into many cli tools on Linux.
I know I can create aliases and whatnot, but I'm a consultant, when I was still hands on with the tools I'd log into 30+ different customer's environments every year. Many were isolated from the Internet and whilst I did carry my dotfiles around on a USB (Along with some binaries of useful tools that are so often lacking on enterprise systems) I couldn't always use them.
It's not even that the "Terms of Service & Privacy" link doesn't work, it's that it's not even a link. It's a div that sorta behaves like a link. Shady af.
This is great. Is there an easy "open source terminal emulator" where I can run this after I typed enter but before it is executed? More like. is there a way the terminal can understand I typed a bad command and then give suggestions for changing it.
GNU Emacs has a module called eshell-smart that borrows from Plan 9's 9term.
When you run a command it moves the cursor (point in Emacs) to the beginning of the line and shows output below it.
If you start typing it jumps to a new prompt allowing you to enter a separate command.
If instead you move right from the beginning of the line it sees you are correcting/tweaking the command and doesn't jump to a new line when you type something.
If you press space it acts like a pager.
It's pretty neat because it allows you to review the output without getting in the way.
Damn, imagine working at a place where at the end of each day, the management goes through your shell history and includes it in a "performance review".
Personally I like getting insulted by my tools. I always put `Defaults insults` in my /etc/sudoers file so every time I enter the wrong password, I get insulted. I wish more tools supported this. I think computing in general is fun, and wish more tools had fun things like this.
$ sudo whoami
[sudo] password for user:
Your mother was a hamster and your father smelt of elderberries!
[sudo] password for user:
Your mind just hasn't been the same since the electro-shock, has it?
[sudo] password for user:
sudo: 3 incorrect password attempts
Reminds me of the days installing sl on FreeBSD servers. Someone typos the most common and basic of commands and they watch a steam locomotive journey across their screen. It even has different versions based on common ls switches.
Hey guys, I've created a really small tool that converts natural language into terminal commands using GPT3. To my chagrin, I seem to have a pathological inability to remember commands so I'm hoping this may help others suffering from such a terrible affliction.
When I first read this comment I assumed it was someone sarcastically pretending to be the creator and not the actual creator, and I thought, what a dick... LOL
Looks neat! I've already been using github copilot which I've found brings some more joy into coding (even when it's a little off).
Yea, it's not the full prompt, I've been gradually training it over the last couple of weeks. It still needs work though as it's quite rudimentary at the moment. Something I intend to focus on going forward.
Am I crazy to think that a tool like this is an accident waiting to happen?
I'm assuming that this tool is for people who aren't familiar with the system enough to get what they need from the man pages and would rather not invest the time to become deeper on it.
If you don't remember the command you need to use, how can you be sure it is the correct command and options before you run it?
It shows you the command and allows you to copy it on the clipboard. It's never going to execute it. For me it is useful more like a refreshing your memory than doing the actual work, therefore you need to know what you're doing from previous knowledge.
On the other hand if you are doing something dangerous or risky or you don't understand the suggested command, maybe you shouldn't use this tool without searching more info first.
>It shows you the command and allows you to copy it on the clipboard. It's never going to execute it. For me it is useful more like a refreshing your memory than doing the actual work, therefore you need to know what you're doing from previous knowledge.
That sounds suspciously like smitty[0].
Which was a useful tool when I was learning AIX. I'd expect a similar tool could be useful for learning other systems too.
Guess-and-verify seems like a good strategy here. Maybe I'm not even sure which command I should be using for some task, but once I've been given a command and some options I can go read the man page to verify they do what I want
I just make bash functions in my dotfiles for use cases like these, particularly good CLI arg combinations from Stack Overflow answers, etc.
Example:
# 2022-02-07
# because `poetry show --outdated` includes *all* packages (!), not just top-level dependencies
function poetry-show-outdated {
poetry show --outdated | grep --file=<(poetry show --tree | grep '^\w' | cut -d' ' -f1)
}
Or:
function disk-usage-summary () {
# output high-level disk usage stats
set -x
du --human-readable --summarize
du --human-readable --max-depth=1
df --human-readable --total
set +x
}
If I don't necessarily want to run all of the commands, I make a "do-nothing script" [1][2] that just echoes them out instead.
I don't have a generalized example of undo / redo in bash commands, since I don't believe it's possible, but for example, if I'm running a destructive command, I prefer to run the dry run version first, then have a confirmation prompt [3] before running the destructive action.
McFly uses either a neural net or fzf along with sqlite and clever script hooks to do basically everything you may need: https://github.com/cantino/mcfly
Wow, thanks for the tip! This looks really useful, I've been using fzf for a long time and it works well but this seems like a clear improvement to that
The quick demo looks pretty dope, but I am never gonna pay a subscription for a closed source token-identified cli tool. I would have paid a one time fee for a similar tool that doesn't phone home to check my api key every time I use it.
My guess is that it's relying on openai calls to do the hard work, and thus someone has to pay for them. I believe that GPT-3, which this relies on, is not open source and probably not easy to run on your device.
Microsoft announced on September 22, 2020, that it had licensed "exclusive" use of GPT-3; others can still use the public API to receive output, but only Microsoft has access to GPT-3's underlying model.https://en.wikipedia.org/wiki/GPT-3
Looks nice; how does it work under the hood? It looks like it needs an API key, so does that mean it sends all my inputs to some server? Does it taylor the answer based on your OS, like using Hombrew on Mac and apt on Ubuntu? Can it work offline?
So it's using the GPT-3 API, so yes, don't send anything sensitive! It doesn't taylor it based on your OS but that's actually a really neat idea, something I'll look to add. For now though, you can just write "how do I x on mac?" and it should work.
This looks like a fun idea. I'm curious, is GPT3 used to generate the commands, or only to parse the input? I'd personally be very wary to use any GPT3 generated command since there's no guarantee that it wouldn't be destructive.
I don't know because I'm from the "if you need to write down multiple examples of how to use a command in order to move forward with it indefinitely, then it has an absolutely terrible UI and that is in fact the root problem you should be fixing" school of thought.
I'm the kind of person that prefers wrapping commands with terrible UI in functions with much better UI though https://github.com/pmarreck/pac . Like who the fuck thought that "pacman -Syyu" (where the number of y's semantically changes the meaning) would be a great idea? An idiot, a sadist or an autist, that's who. Certainly not someone who actually cares about normal humans.
In my opinion, instead of writing all these helper or cheatsheet functions as constant reminders of how bad the TUI (text user interface) is on these commands, someone should release a library of wrappers that wraps all of these turds (I'm sorry, "diamonds in the rough") in sensible and consistent TUI with consistent option formats, autocompletes, maybe some inline documentation while you type the command, etc. And then we wouldn't need all these band-aid tools.
I can say as an Arch fan but pacman command-tool despiser (did I mention that it doesn't at all try to stop you from easily breaking your dependency structure JUST in order to support some very corner use-cases?), prior to writing pac I was "man pacman"'ing for months, and after I finished it I haven't needed to do that EVER. (Yet.)
The "ip" command is an example of one I'd say has a good TUI.
CPANPLUS::Internals::Source::Memory(3pm) - In memory implementation n .SS "$cb->_|_memory_retrieve_source(name => $name, [path => $path, uptodate => BOOL, verbose => BOOL])" .SS "$cb->_|_memory_retrieve_source(name => $name, [path => $path, uptodate => BOOL, verbose => BOOL])" Subsection "$cb->__memory_retrieve_source(name => $name, [path => $path, uptodate => BOOL, verbose => BOOL])" This method retrieves a storabled tree identified by $name. It takes the following arguments: name" 4 Item "name" The internal name for the source file to retrieve. uptodate" 4 Item "uptodate" A flag indicating whether the file-cache is up-to-date or not. path" 4 Item "path" The absolute path to the directory holding the source files. verbose" 4 Item "verbose" A boolean flag indicating whether or not to be verbose. Will get information from the config file by default. Returns a tree on success, false on failure. n .SS "$cb->_|_memory_save_source([verbose => BOOL, path => $path])" .SS "$cb->_|_memory_save_source([verbose => BOOL, path => $path])" Subsection "$cb->__memory_save_source([verbose => BOOL, path => $path])" This method saves all the parsed trees in storabled format if Storable is available. It takes the following arguments: path" 4 Item "path" The absolute path to the directory holding the source files. verbose" 4 Item "verbose" A boolean flag indicating whether or not to be verbose. Will get information from the config file by default. Returns true on success, false on failure
I used to have a hard time remembering apropos because I assumed 'apropos' was some sort of unixy mincing of another word or abbreviation or something, and I couldn't figure out what it meant. You know, like 'mkdir' means "MaKe DIRectory"
But it turns out apropos is just a regular word. Once I learned this, I haven't had any more trouble with it.
Ohh I always thought "apropos" was from the French expression "à propos (de)... " which means "about". I naïvely believed that the person who coded this command must be French.
The English usage is borrowed from French![0] However, it doesn't look like the original author was French[1]. I shouldn't be, but I am quite surprised to see that the apropos command as we know it is 43 years old!
Then, I have a script called "findcmd" that simply greps my .unique_bash file.
for var in "$@"
do
cmd="| grep \"$var\" $cmd"
done
cmd="cat ~/.unique_bash $cmd"
eval $cmd
In the end, when I need to figure something out, I head to the internet. Those commands are then captured for posterity in the .unique_bash file. If I want to know how to post a JSON file to an endpoint using Curl, then
$ findcmd curl json
And all those curl commands show up.
It won't let me do something I don't know, but it make my memory much, much longer.
And, yea, I admit there have been instances where I've completely forgotten the command, and had to head back to the web. But when I've done that, I can hit my history and see how I used it.
If, sometimes, a "bad command", a command done wrong, too many of the same thing, just lingers, I can go edit it out. But most of the time I don't bother.
You might enjoy the fzf (fuzzy finder) tool configured for your shell's history search keybinding (most likely Ctrl+R). I can't elaborate at the moment, but essentially you type Ctrl+R, start typing roughly what you want and fzf searches your shell history based on what you typed. It works extremely well for me. Based on what you described, fzf Ctrl+R should be your workflow on steroids.
Nice work, I wanted to add how I deal with this.
first my .bashrc Is setup to append and history is set to 100,000 lines.
Most importantly I have an alias set up for the letter h , that greps, case insensitive .bash_history. ( grep -i $1 .bash_history ).
So typing in the cli:
# h awk
gives me all my awk commands.
And second , as a global history search across all my VMs/instances, (as I already make extensive use of splunk and splunks universal forwarder log forwarding app/tool) , all vms have their splunk universal forwarder service set to send any updates to .Bash_history to my central spunk server. thus I’m able to globally search the bash history from any VM globally, going back forever (I search that via the splunk web gui i mean).
All works great!
Thank you! You just improved my workflow and that does not happen every day. A spin I think I might add is to output all commands that do not result in standard error to a separate history file. .bash_history_no_error or something like that.
(Unrelated to original post) That only helps if you know the keywords curl and json. My actual problem in the past has repeatedly been that I a) forget how the graphical file manager on my system is called because I use it a couple of times per year (dolphi, konqueror, thunar, whatever...) and b) I use i3 or xmonad and don't have a "start menu" to just browse.
I think I should just put a symlink called explorer.exe in my ~/bin/ and then I know where to look ;)
Anytime I sign into a system I have not signed into for a long time. The first thing I do is save the history file before I start working. Many times it has saved the day when you get stuck: where did I store that config? what was the command to restart the server?
Because a man page for how to remove a limit of 50 files in a certain directory created after a certain date is equal to an AI-powered script to make the entire almost unreadable command in 2 seconds.
nobody knows enough from reading manuals for UN*X because it is too hard. everyone I talk to who says they have done it are still missing fundamental info, like for instance any one i talk to will probably not undersand that sudo is insecure for 99% of use cases and start crying when i explain to them that you can just use ptrace to capture the password or replace some bash envars to hijack the command. nobody knows how to declare a variable in a signal handler (see signal handling for fun and profit), because there is no comprehensive overview of C called "stuff you should know before actually programming in this".
the problem with trying to learn a UN*X system from within is that everything is scattered everywhere, and there is no comprehensive overview of any part of the system (they try to make some, but they are always missing something important, or dont mention how this would work in the context of a practical system where other subsystems change the behavior and requirements of this one), and the parts which take too long for anyone with a life to learn are always changing, like in linux ip tools, iptables/whatever alternative, and PAM, init (init is hard because you have to learn about how to manage environment and session properly which involves some tens of pages of man pages enumerating subtle details) systemd, pulseaudio. every tool has its own DSL for the trivial task of accepting parameters and parsing configs. to use apropos you first have to setup some database thing (yeah i dont remember).
learning C libs from the man pages is a perfect example. to do trivial stuff requires some hours of reading every day, and when you come back to use those functions again you will not remember most of them and have to look them up again, and they are:
- full of irrelevant info, the "BUGS" section, the "examples" section, conformance issues (which are not something you have in other languages' libraries),
- unneeded "this and that is UB" followed 5 minutes later by realizing 5 other things they did not write about is UB followed by philisophical pondering about why they list one UB when you still need to think for yourself to know what is actually UB, etc.
- 10 different ERRNOs. you need to read all of them in case there is some fundamental info listed there and not elsewhere in the man page you are reading
- some wacky crap like sockaddr_t with casting or an integer split across two parameters (btw socket programming in itself is its own clusterfuck to learn from man pages alone. yes i have done it on one foray into socket programming)
which is why C is not suited for general purpose programming - it has too many edge cases for anyone but the most very strict programmers (most of whom consider themselves to be so are in fact not) who already worked on 3 big programs. you cannot use this for 10s of thousands of lines of CRUD like what gnome or whatever does. the average open source UN*X C program is a buggy mess.
then there's also the problem that you can't do anything in UN*X without learning at least 5 different programming languages. this also means you will not have rigid understandings of them all and make common easy to spot bugs. or you can spend hours a day reading about every expression you will invoke and get fired.
one time i had to setup a secure system with some C glue code involving a socket. it took 2 or 3 days to be somewhat sure i am not invoking some kind of UB in this 100 lines of code and that all my file semantics (permissions, timings) were right (also another source of huge complexity for something that should be trivial).
UN*X is a pyramid scheme. whenever you complain about it, someone will say "you're just not man enough to have learned it properly". no matter what you do there will always be this theoretical case of someone more manly than you who has succeeded in UN*X (whatever that means). go try again for another 2 years. of course this is all nonsense, as the averge joe dev or sysadmin in the industry does everything laughably wrong unless there is a meme circulating about how to avoid problem #3527.
did i explain this enough yet? UN*X is an absolute clusterfuck. its not coherently designed in any way what so ever. to set screen blanking parameters on linux, you write some text to the terminal. this is therefore considered """UN*Xy""", because it has something to do with 2 of their major fetishes. this is the level of insanity that is considered normal.
tl;dr you simply cannot learn a UN*X system sufficiently to be able to have a grounded understanding of it as well as being a productive person. perhaps you can dedicate your life to creating a JSON parser after you graduate UN*X and then die of old age.
I would agree that both C and Unix are highly disorganized/decentralized. There is no standard pattern to arguments passed to commands, for example; if this was standardized as much as possible, Unix would become much easier for noobs. And C? 40+ years later and we are still dealing with bad design decisions in it.
But yeah, this isn't your blog. and also, how in the hell did you get burned by unix this badly?
UN*X is a shithole and just talking about one of the problems with it causes one to pull in the other problems that are inextricably intertwined with each other.
All problems in software development can be solved by another level of indirection. Slow and buggy neural networks are especially suited for such a task.
I'm sure these are just oversights but it leaves a very bad taste in my mouth!