Shell Tricks That Make Life Easier (and Save Your Sanity)
71–80 of 287 posts
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#72Something like this:
# Prevent certain strings from appearing in the history
# Anything starting with a leading space is ignored
# Anything containing "--force" or "whatever" is ignored
function zshaddhistory() {
emulate -L zsh
if ! [[ "$1" =~ "(^ |--force|whatever)" ]] ; then
print -sr -- "${1%%$'\n'}"
fc -p
else
return 1
fi
}Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#73Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#74What I hate is that if you start a command with a space it is not recorded in the history. This happens often when copy+pasting commands. I know you can turn it off but still ... this drives me mad.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#75`CTRL + U and CTRL + K CTRL + W`
What I like about these key combinations is that they are kind of universal. A lot of programs on Linux and Mac support all these key combinations out of the box. And that's like a game changer in productivity, especially jumping to the start or the end of the line or jumping forward and backward per word is making working only with the keyboard so much more nice. And in editors together so AVY, you can even get a faster flow of jumping around.
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#76 Ctrl + _ (Ctrl + underscore)Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#77Earlier quoted context omitted.
What does it provide over mycmd1 #| mycmd2
Theirs "turns off" one element of a pipeline; yours turns off everything after a certain point. This will output the stdout of mycmd1: mycmd1 #| mycmd2 | mycmd3 This will output the stdout of mycmd3: mycmd1 | \# mycmd2 | mycmd3
I've somehow gotten by never really needing to pipe any commands in the terminal, probably because I mostly do frontend dev and use the term for starting the server and running prodaccess
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#78I'd advise against using sudo !! though since it adds the command to history and then it's very easy to accidentally trigger, running some undesired command as root without any prior confirmation. IMO pressing up, Ctrl-A and typing "sudo " isn't much longer but saves you from running unknown commands as root by accident
Re: Shell Tricks That Make Life Easier (and Save Your Sanity)
#79Earlier quoted context omitted.
I've been a (n)vim user for 20+ years now, but I hate vi-mode in the shell. However if I feel that I need to do a complex command, I just do ctrl-x+e to open up in neovim (with EDITOR=nvim set). I find it a good middle ground.
Huh. I don’t use vi-mode for more than jumping to the beginning or end of a line, which I like a lot.