trick tip: sucker punch for forums/irc with rules

Talk about anything you feel like talking about. Pull up a soapbox and pontificate to your heart's content. May contain some adult humour or otherwise objectionable content (NSFW). No warez, pr0n or illegal stuff.

trick tip: sucker punch for forums/irc with rules

Postby nodir » October 16th, 2018, 10:56 am

apt-get install thefuck
Last edited by nodir on October 17th, 2018, 1:35 am, edited 1 time in total.
nodir
 
Posts: 305
Joined: June 16th, 2015, 10:10 pm

Re: trick tip

Postby Head_on_a_Stick » October 16th, 2018, 6:56 pm

^ I love that program :)

Some other correctional options with bash:
Code: Select all
bash-4.4$ echi hello
bash: echi: command not found
bash-4.4$ ^hi^ho
echo hello
hello
bash-4.4$

^ The carets allow a sed-like substitution.

And this old favourite:
Code: Select all
bash-4.4$ hello
bash: hello: command not found
bash-4.4$ echo !!
echo hello
hello
bash-4.4$
Show Off
User avatar
Head_on_a_Stick
 
Posts: 163
Joined: June 16th, 2015, 8:35 pm
Location: London baby!

Re: trick tip

Postby nodir » October 17th, 2018, 1:21 am

I put this in nonsense for a reason.


But if you want to show your foo:
How can i access the arguments/options not the last? so:
mkdir foo bar baz
and i want bar
printf "second arg of last cmd was %s\n" "!$"
"!$" being the last, but what is the first, what is the one before last, etc ... ?

I am not shitting you. I am looking for that for quite a while now (well looking means: every other day i could use that. Usually i need !$ and that's it mkdir/cp/ /long/path/ && cd $?
I ain't got much problems with wrong spelled commands, as i mainly use alternative history completion from inputrc.
nodir
 
Posts: 305
Joined: June 16th, 2015, 10:10 pm

Re: trick tip

Postby Head_on_a_Stick » October 17th, 2018, 9:00 pm

nodir wrote:How can i access the arguments/options not the last?

Oh dear, sorry nodir I have no idea — I'm no coder and my foo is practically non-existent.

Sorry if I posted inappropriately, I didn't mean to derail your thread.
Show Off
User avatar
Head_on_a_Stick
 
Posts: 163
Joined: June 16th, 2015, 8:35 pm
Location: London baby!

Re: trick tip: sucker punch for forums/irc with rules

Postby nodir » October 18th, 2018, 2:55 am

might be an idea instead of installing something new because it is new to first make sure to know what the dinosaur is able to do?
From what i read of you i bet you run zsh or an according new shit (which indeed might be better. Thing is: takes someone who is able to see it).
I for one know shit. That's not the point.
nodir
 
Posts: 305
Joined: June 16th, 2015, 10:10 pm

Re: trick tip: sucker punch for forums/irc with rules

Postby Head_on_a_Stick » October 18th, 2018, 5:28 am

nodir wrote:From what i read of you i bet you run zsh

I used to use that a while ago (with grml's excellent configuration) but I grew to love Korn shell when I started using OpenBSD so I now favour a statically-linked version of mksh, I have a package for it in the AUR:

https://aur.archlinux.org/packages/mksh-static/
Show Off
User avatar
Head_on_a_Stick
 
Posts: 163
Joined: June 16th, 2015, 8:35 pm
Location: London baby!

Re: trick tip: sucker punch for forums/irc with rules

Postby nodir » October 18th, 2018, 6:07 am

you prefer zsh over bash and mksh over zsh.
Why? You really do that much cli stuff? Of course i can loo up the advanteges of zsh and mksh myself. The question is: you really fully make use of any of the three?
To me the answer is simple: a) i know a few little tricks when using bash and b) there are way more good tutorials out there how to learn new tricks.
I do know that both are better. The question is: are they better for me (or you).

fossil is better than git. tmux is better than screen. dwm is better than awesome. I for one am done with hunting ...
nodir
 
Posts: 305
Joined: June 16th, 2015, 10:10 pm

Re: trick tip: sucker punch for forums/irc with rules

Postby Head_on_a_Stick » October 18th, 2018, 6:17 am

nodir wrote:you prefer zsh over bash and mksh over zsh.
Why?

Not quite, I used to love all the functionality of zsh (the globbing is almost supernatural and grml's advanced tab completion works like magic) but after working with Korn shell for a while I realised that I could manage without all those bells & whistles and all I really need are basic tab-completion, globbing and expansion.

The Korn shells use a fraction of the memory of either bash or zsh and are *much* faster — I posted some benchmarks in another forum: ksh93 in particular was 10 times faster than bash when iterating through loops (ksh93 avoids subshells at all costs).

nodir wrote:You really do that much cli stuff?

I prefer to control stuff from the command line, GUIs annoy me. I don't script much though, I don't have the patience (or talent).
Show Off
User avatar
Head_on_a_Stick
 
Posts: 163
Joined: June 16th, 2015, 8:35 pm
Location: London baby!

Re: trick tip: sucker punch for forums/irc with rules

Postby nodir » October 18th, 2018, 6:20 am

whats wrong with tab completion in bash? expansion and globbing too ? What are you *really* missing?

besides: what loops do you really run regularly where the difference is noticable? If at all i loop over, say, 10 or 20 items.
That is not a good reason for me to give up on the well known and well documented tricks of bash. It would be, if someone could tell you how to do xyz in any other shell.
real life example, as far my little corner of the world is concerned:
Code: Select all
# bin/dragora_chroot -m
root@voidlinux:/# exit
exit
# mount | awk '/media/ { print $3 }' | sort -r | wc -l
19
# time mount | awk '/media/ {print $3}' | sort -r | while IFS= read -r mp; do umount "$mp"; done

real    0m0.175s
user    0m0.030s
sys     0m0.066s
#

doesn't bug me.

Code: Select all
  1.2 MiB + 231.0 KiB =   1.5 MiB       mksh (6)
  2.4 MiB +   1.6 MiB =   4.0 MiB       bash (6)

doesn't bug me either.


I prefer to control stuff from the command line, GUIs annoy me. I don't script much though, I don't have the patience (or talent).

with "much" i meant rather: much of the features of any of the given shells.
nodir
 
Posts: 305
Joined: June 16th, 2015, 10:10 pm

Re: trick tip: sucker punch for forums/irc with rules

Postby Head_on_a_Stick » October 18th, 2018, 4:14 pm

nodir wrote:whats wrong with tab completion in bash? expansion and globbing too ? What are you *really* missing?

It's not that bash is missing stuff for me, it's that bash does too much and offers too many features that I would never use (such as associative arrays) whereas the Korn shells are more stripped down and lightweight whilst still offering the stuff I do use.

nodir wrote:besides: what loops do you really run regularly where the difference is noticable? If at all i loop over, say, 10 or 20 items.

The loops were just the method I used for the benchmarking but I make a live rescue ISO with my own configuration and the terminals are noticeably "snappier" on old hardware when mksh is used instead of bash.

nodir wrote:with "much" i meant rather: much of the features of any of the given shells.

I only use stuff like expansion, simple globbing, here documents and the occasional loop. The bare-bones mksh shell handles this all just fine with lower overheads than bash (or zsh) and it's faster as well
Show Off
User avatar
Head_on_a_Stick
 
Posts: 163
Joined: June 16th, 2015, 8:35 pm
Location: London baby!

Next

Return to Nonsense

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x