Earlier quoted context omitted.
I use Emacs shell-mode for most of my terminals, which allows navigating and editing the buffer just like any other file. I'll often make several copies of a command, then use a macro to alter each one; after checking that they look right, pressing Enter will send them all to the shell.
I always tried to use the shell with emacs (eshell, multi-term) but it didn't render correctly curses and all the fancy stuffs like emojis. Out of curiosity, how do you manage that?
Moreutils – Unix tools that nobody thought to write (2012)
101–110 of 225 posts
Re: Moreutils – Unix tools that nobody thought to write (2012)
#102Earlier quoted context omitted.
Linux on ARM is a very mainstream platform from the perspective I’m looking at this from, I’m afraid. I’m talking about strange Unices running on architectures that GCC may or may not maintain a backend for, or maybe a BusyBox available on some debug interface, maybe a school project to build a simple POSIX-compatible OS or a bootstrap for a platform that had been recently jailbroken. In these cases C is almost alway…
Could you give some actual examples? This sounds interesting but I'm not sure I've ever seen something like that in the wild.
(I have some patches to improve things but I have not been able to submit them to LLVM yet, and with those patches I did manage to get a working x32 build of rg on my system. I hope to be able to do so in the future.)
Re: Moreutils – Unix tools that nobody thought to write (2012)
#103Earlier quoted context omitted.
The purpose of sponge is that you can do this: grep foo file.txt | sponge file.txt If you do this with redirections then file.txt will be truncated before it's been processed, leaving you with an empty file instead of what you wanted. Sponge collects its input first and then writes everything out at the end, so you can output to a file that was used as an input. (Parent updated while I was writing. Oh well)
That doesn't seem like an efficient way to do it. Commands that process file in place (sed -i) write to a temporary file in the same filesystem and then rename to the target file, which works if you want to process files that don't fit into memory.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#104On another note
> pee: tee standard input to pipes
Goddammit guys!
Re: Moreutils – Unix tools that nobody thought to write (2012)
#105A lot of these seem easily achieved in a POSIX shell manner, but most annoyingly to me > sponge: soak up standard input and write to a file I do that all the time... cat > file.txt Update: reading the comments on here, apparently sponge sucks up all content before opening the destination file which allows editing an input file in place. Minor advantage there.
Not minor; it's literally the point of this tool
Re: Moreutils – Unix tools that nobody thought to write (2012)
#106Earlier quoted context omitted.
I think that's the default behaviour in Zsh or Fish if you press tab.
Probably immediate subdir. What I am talking about is universal jump-to-anywhere. Like I have subdir "/media/tnoko/sdc1/capture/Roinaa/". "ncd Roi" should be totally sufficient and unique command to go there.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#107Where is Msdos utility "ncd"? It was like "cd" but guessed from few character hint where you wanted to go. If the choice was not immediately obvious if offered a menu or a tree. I shortened it to "n". -- There was some linux utility but setting it up was annoyingly tedious, with lots of useless and cryptic options.
But I already made my own. It is quite perfect:
#! /bin/bash
d=$(find / -name "$1" 2>/dev/null | head -1)
echo Jumping to $d, Control-D to return
sleep 1
cd $d
bashRe: Moreutils – Unix tools that nobody thought to write (2012)
#108Earlier quoted context omitted.
The purpose of sponge is that you can do this: grep foo file.txt | sponge file.txt If you do this with redirections then file.txt will be truncated before it's been processed, leaving you with an empty file instead of what you wanted. Sponge collects its input first and then writes everything out at the end, so you can output to a file that was used as an input. (Parent updated while I was writing. Oh well)
That doesn't seem like an efficient way to do it. Commands that process file in place (sed -i) write to a temporary file in the same filesystem and then rename to the target file, which works if you want to process files that don't fit into memory.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#109Earlier quoted context omitted.
But the top answer has it: > find . -maxdepth 1 -type f A little clunky, but there's certainly no need to mess about in JavaScript land. If you use it often, create a shell macro.
find doesn't return the same output as ls when run on another directory. Maybe there is a switch to do this? I'm not sure. $ mkdir -p tmp && touch tmp/a tmp/b tmp/c $ find ./tmp -maxdepth 1 -type f ./tmp/a ./tmp/c ./tmp/b $ ls -1 ./tmp a b c
+ $ find /tmp/x ! -path /tmp/x -prune -type f -exec sh -c 'for p; do printf '\''%s\n'\'' "${p##*/}"; done' - {} +
c
b
a
Seems to do the trick and is POSIX only (so works on busybox and mac). You can probably just tack `| sort` at the end if you want it sorted.Re: Moreutils – Unix tools that nobody thought to write (2012)
#110 sed "s/root/toor/" /etc/passwd | grep -v joey | sponge /etc/passwd
I think it can be rewritten as: sed -n '/joey/! s/root/toor/p' -i /etc/passwd