//*
normal path
/*/
debug path
//*/
take away the the first slash to toggle the debug zone ON!Small programming tricks (will-keleher.com)
customguy 2 hours ago
normie3000 an hour ago
penguin_booze 44 minutes ago
#if 0
// Normal path
#else
// Debug path
#endif
Only works with C and C++, though.phforms 15 hours ago
Usually what I do is writing these tricks down to a document that is easily accessible at a place where I know that I will look for when failing to remember them. I have a directory of docs where I write stuff like this down by language/tool/etc., so I can quickly look it up without having to search the internet. But I also have to actively remind myself that these things exist whenever I have a problem, stop me from just doing the inefficient thing.
diath 15 hours ago
It's not even that bad of a habit with zsh either where it will only scroll through history matching a substring in your history, for instance if I type "rg -i" and then start pressing up arrow, it will only cycle through history entries starting with "rg -i".
weaksauce 14 hours ago
though one function that i recently added will narrow your history down based on a space separated set of filters which i found useful
function hgrep
set -l cmd history
for pattern in $argv
set cmd "$cmd | grep -- "(string escape "$pattern")
end
eval $cmd | cat
end
use `hgrep ruby debug foo` would filter for a line that contained all the words ruby, debug and foo.harikb 14 hours ago
chrisweekly 13 hours ago
type eg "rg" then up or down arrow, and the history shown is filtered by that rg prefix.
saghm 7 hours ago
applicative 12 hours ago
bindkey '^[[A' history-search-backward
bindkey '^[[B' history-search-forward
So far it works. Thank you diath.saghm 7 hours ago
mkehrt 5 hours ago
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
quirino 15 hours ago
ChickeNES 14 hours ago
ellieh 14 hours ago
yes, it's improved a lot in the last couple of years! what in particular bothered you?
saghm 7 hours ago
ellieh 6 hours ago
Make sure you’re using the daemon (the install script will handle this) and you should be good to go
Very happy to help if you have any problems. Ellie at Atuin dot sh
saghm 6 hours ago
zem 10 hours ago
SAI_Peregrinus 12 hours ago
dec0dedab0de 13 hours ago
pards 13 hours ago
asdfman123 12 hours ago
justonenote 12 hours ago
what a time to be alive.
UnfitFootprint 11 hours ago
I think for a digital solution to come close you need it permanently present on a nth monitor
sublinear 11 hours ago
Seems like overkill until it saves my ass. It continues to do so almost half a decade into all the LLM hype. It hits the sweet spot between simplicity, convenience, reliability, and precision.
People strongly underestimate how good the git life can be, especially with all the blogspam on here trying to dethrone it lately.
guenthert an hour ago
Don't let IT hear that unless you work on FOSS.
zem 10 hours ago
reaperducer 13 hours ago
People had this same problem last century. They would use templates that fit over their keyboards with all the common shortcuts and commands printed on them. Sometimes they were for a specific program, but you could buy blank ones to write your own notes.
Today, "keyboard templates" have an entirely different meaning, so the best thing for this is paper. Print your shortcuts out on a piece of paper and put it near your monitor. You could even categorize them by writing them on different-colored Post-Its.
fragmede 13 hours ago
lelandbatey 12 hours ago
irishcoffee 11 hours ago
wild_egg 10 hours ago
jwpapi 11 hours ago
sameerds 5 hours ago
autoexec 4 hours ago
kulahan 9 hours ago
So if you want to use ctrl-r, but you’re using the up key, use the down key to navigate back to a clear line, then use ctrl-r. Do it enough times and your brain will work overtime to find a shortcut (aka just doing it the new way).
or_am_i 4 hours ago
estetlinus 3 hours ago
jachee an hour ago
gregdeon 6 hours ago
kenniskrag 3 hours ago
alentred 2 hours ago
I always wanted the same for Vim, zsh, etc.
sassbadger 2 hours ago
kwbr3000 2 hours ago
alentred 33 minutes ago
kccqzy 16 hours ago
teekert 16 hours ago
louthy 16 hours ago
Is this just plain old rage baiting? I literally can’t tell any more.
kccqzy 15 hours ago
lencastre 15 hours ago
bigstrat2003 15 hours ago
Those are also the current days if you have any sense. It's a bad idea to run an LLM with access to your machine at all, but if you absolutely must, you better review everything it does to make sure it doesn't run anything insane.
kccqzy 15 hours ago
TeMPOraL 13 hours ago
The rest of us picks a level between "approve some" and "YOLO" depending on how much they worry about having to clean up the workspace afterwards. Encouraging using the repo and some dedicated per-session storage, while discouraging changes to global state (like installing packages system-wide) reduces cleanup problem to "every now and then `rm -rf` some agent session dirs".
throwaway219450 14 hours ago
There are other terminal specific shortcuts for removing last word (ctrl+w) but they don't seem to be as portable.
gosub100 14 hours ago
TeMPOraL 13 hours ago
zem 10 hours ago
mkehrt 5 hours ago
stty -ixon
throwaway219450 4 hours ago
zh3 an hour ago
The advantage of doing it this way ('software flow control') is it worked with just TX and RX lines, rather than having to connect up additional wires to indicate when the terminal was busy ('hardware flow control').
kccqzy 13 hours ago
mkehrt 5 hours ago
SAI_Peregrinus 12 hours ago
sprinkly-dust 14 hours ago
I haven't put in enough effort to replicate the experience on GNOME but once I jump ship from Apple I'll have to.
The way macOS treats shortcuts thanks to the separation of Command and Control is great. It even makes Google Docs pretty painless to use because it's mostly like Emacs. Word still tries to hijack the shortcuts so that's suboptimal.
ifyoubuildit 13 hours ago
cirelli94 2 hours ago
zem 10 hours ago
noduerme 5 hours ago
--date=2026-09-16
--date 20260916
and all variations thereof. It's annoying enough to have to check which script expects what format that I probably should've wasted some time or tokens to align them all, or at least put it into an MD file. But it's just an illustration of how LLMs can make CLI commands more obscure than they need to be.
hiAndrewQuinn 38 minutes ago
https://github.com/hiAndrewQuinn/shell-bling-ubuntu
More readable presentation: https://hiandrewquinn.github.io/shell-bling-ubuntu/
Among other things, fzf gets installed with all the proper key bindings, ripgrep, fdfind... basically every papercut I could find between going from a vanilla Ubuntu or Debian box to a configured one is handled in this shell script.
ozim 12 hours ago
Anyways I find it mind boggling how many useful actions are not known by „normal people”. Most people are really using computers in a very inefficient way.
My idea is if we would spend time making people learn computers or software they use daily better - we wouldn’t need AI agents and we would triple GDP.
xhevahir 12 hours ago
layman51 5 hours ago
autoexec 4 hours ago
There's no amount of skill/efficiency/productivity a human worker can reach that will make employers give up on the dream of one day replacing them with software. The AI companies looking to profit from renting out the collected works and creativity of humanity certainly wouldn't shut down if the GDP tripled either.
People should still take time to learn how to use computers though. As long as they're going to use computers they can save themselves a lot of trouble and anxiety by investing some time in learning about them a little. Same with many other things people use and depend on.
GNOMES 13 hours ago
https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9...
I use this often instead of chaining together multiple '../..'.
Also nice for when I use Zoxide to CD into a deep nested directory. I quickly found out unless you manually CD each hop, the different parent directories aren't added to your Zoxide DB. (I have come across snippits to recursively CD into all directories in a path to "prepopulate" Zoxide).
I made this to jump directly from say `/foo/bar/batz/abc/123` to `/foo/bar/batz`.
exdeejay_ 13 hours ago
RhysU 10 hours ago
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
Just keep typing period and hitting enter until you get where you want according to your prompt. I haven't found much use for more than four periods. One period would be well-defined but useless.zh3 an hour ago
#!/bin/bash
# SSH to remote system and change into same (current) directory
DIR=$(pwd)
ssh -t $1 "cd $DIR; bash -l -i"urxvtcd 43 minutes ago
gnoack 16 hours ago
The "Unix Power Tools" book is an excellent source for Unix and shell usage tricks
sixtyj 15 hours ago
NegativeLatency 17 hours ago
I would find that annoying, however to not be seen as a jerk I wouldn't say anything.
blooalien 16 hours ago
CableNinja 16 hours ago
I frequently do the same, but not everyday; only when i think its something actually useful/helpful beyond the everyday crap. Most recently, we have had a huge push to use ai (just like everywhere else), ive been getting pretty creative with it, and at this point have a well polished setup that i can give a shitty sentence on a problem, not only does it understand the task, but theres a full ticket->branch->work->pr review->ready comment flow that it uses. My team also uses ai but they havent quite wrapped their head on ways to really work with it. I have built and shared a number of helpful things with the team to try and help them grow. One such thing was a doc i had my ai instance write, based on how ive been using my setup. This alone has started to get the rest of the team up to where i am.
My team doesnt share the same types of things i do, but they still share helpful things.
Call it what you will; I think if youre not helping your team grow by providing insights and helpful things, then youre not the kind of person i want to work with.
NegativeLatency 16 hours ago
One is actually helping and the other is making yourself more visible to mgmt for promotions.
metabagel 16 hours ago
davidee 15 hours ago
Share knowledge? I don't think anyone here is arguing against that in any way (or conversely arguing for hoarding knowledge).
The concern, one I share, is where the sharing has to happen publicly "every day" - so no matter how trivial, useless, niche, overly-specific the tip is (whatever, the list isn't exclusive), someone shares it.
That's the part that's not sharing knowledge for the benefit of others, but rather self-serving. I might even go so far as to say self-serving doesn't even need to be selfish; the person might genuinely believe they're doing good, but even there, self-serving.
TLDR: Share your knowledge, don't make sharing something every day, even when you don't have something valuable to share, your target.
PS - if this note irks anyone (are routine maxxers a thing?), make the goal to learn something every day, then share where appropriate.
aquariusDue 15 hours ago
Offering to teach someone something proactively? Sure, go ahead.
Sharing stuff freely when asked and arming someone with the tools to investigate further? Amazing!
Treating a public channel like ye olde facebok wall? Mildly annoying.
BeetleB 14 hours ago
Every team/department/org/whatever should have channels everyone should subscribe to, and channels individuals set up that are optional for everyone. The appropriate way to handle this is for the OP to write a few tips once in a while in the public channel, and if people seem to like it, announce that all future tips will be in that channel.
soulofmischief 13 hours ago
BeetleB 14 hours ago
Most senior engineers I've worked with have forgotten all these tricks, and they actively tell you that while you should try to get better at these things, career gains lie elsewhere. Focus on things with higher impact.
rootlocus 15 hours ago
"Oh, yeah, I know a cool trick, but y'all have to wait until tomorrow to find out what it is."
"Look! It's a way to evaluate SQL expressions with a select with a from! Oh, you already knew about it?"
I have nothing against sharing knowledge, especially when seeing someone else do something that can be done better. But just leaving daily breadcrumbs to remind people you're the guy that teaches random trivia feels like attention seeking.
taink 14 hours ago
I see it more as: every day they will go on the slack channel and pause, wondering "Is there a neat trick I've learned or used recently?" then they share it. It's like a ritual to remember that you can share things because it's easy to forget other people don't work the same way you do. Writing it all at once is difficult (you have to remember a lot of stuff at once) and it tends to go unread.
I also think every single day is a stretch, but it's nice to pause once in a while to think about how you could help other people with something you've learned.
t-writescode 14 hours ago
Both a centralized repository AND a daily message, especially for new employees, would be ideal, imo!
Normalize chatting and sharing stuff in slack!
flumpcakes 9 hours ago
saulpw 16 hours ago
Annoyance is a clue; not about them, but about you.
NegativeLatency 16 hours ago
What I'm saying is I am not a jerk and actually do care about my coworkers, however I also don't want a bunch of noise in a chat app I have to use to do my job.
simlevesque 15 hours ago
NegativeLatency 15 hours ago
>I shared a trick on slack every day with the engineering team
simlevesque 14 hours ago
owebmaster 15 hours ago
saulpw 15 hours ago
Sorry for the "personal attack" but my point stands, you may not think of yourself as a jerk, but I saw your comment and thought "this guy imagining himself being annoyed at a coworker for a daily message with a helpful tip might be more of a jerk than he realizes". As a jerk myself I judged myself qualified to make that assessment and commented accordingly.
mrheosuper 7 hours ago
titzer 14 hours ago
If anything, I wish I had paid a lot more attention to this in the early days and made a nicer shell environment full of my own utilities, as I felt my skills just kind of slowly erode over the years with each migration. Make a nice little nest for yourself and curate those tools as your own (text) UI.
seaucre 9 hours ago
disinterred 16 hours ago
qxxx 15 hours ago
BeetleB 14 hours ago
I rarely type "cd" anymore. A huge quality of life improvement!
maleldil 10 hours ago
1718627440 13 hours ago
SAI_Peregrinus 12 hours ago
cachvico 16 hours ago
CableNinja 16 hours ago
throwaway219450 15 hours ago
FlyingSnake 16 hours ago
jamiejquinn 12 hours ago
RSHEPP 9 hours ago
jamiejquinn 2 hours ago
samdixon 16 hours ago
rootlocus 15 hours ago
reddit_clone 15 hours ago
Still, Zsh history with fzf fuzzy searching is fantastic. I have years of history I can recall commands with a few keystrokes.
Truly a second-brain.
BeetleB 14 hours ago
And as another commenter said, you often forget the target, and use Ctrl-r to find it. Although just does support fzf...
overflowy 17 hours ago
AJRF 16 hours ago
jawns 17 hours ago
popzxc 16 hours ago
IMHO the value of these nuggets is that you understand what you're doing and why; opening yourself to large amounts of non-default behavior likely will end up in a less than pleasant setup.
Not taking into account that different users might disagree on what is convenient and what is not, which is basically the point of making things configurable.
farrellm23 16 hours ago
kccqzy 16 hours ago
rustyminnow 14 hours ago
alentred 3 hours ago
rf15 15 hours ago
welllll that depends entirely on the DB Software you're using. A certain IBM product certainly has opinions on this.
lsofzz 11 hours ago
Folks need to be sufficiently motivated to learn it. All hell break loose when `RTFM` becomes taken offensively; What do I know - I am just a weird guy with a beard.
And folks always wanted to type the commands without RTFM'ing - now we have two problems instead of one.
Also, these were hard learned tricks YOLO'ing until 3.30AM debugging a failed DNS clusters or why the HSM suddenly decided to trip up at 5AM! Nobody even cares about the things we learn these days - Google and then your AI agent already does 98% of what I know already. So, let them blow up the clusters and the racks - your pal AI agent knows. Go ask them instead.
noduerme 5 hours ago
the-mitr 6 hours ago
https://www.gnu.org/software/emacs/manual/html_node/emacs/Ba...
hiAndrewQuinn 33 minutes ago
You can just record and play back your exact keystrokes like a _Super Smash Melee_ game plays back your inputs to replay matches. If you can figure out how to do any mildly complex action once you can literally replay it a thousand times. Just like AutoHotKey! To my that's the essence of citizen programming!
winternewt 17 hours ago
Here's one that I think more people should know: avoid branches. If I can do the same thing without an if statement and even a logical expression, the code typically both becomes easier to understand for people and easier to run for the CPU.
cachvico 16 hours ago
craftkiller 16 hours ago
metabagel 16 hours ago
jamiejquinn 16 hours ago
robby_w_g 16 hours ago
winternewt 14 hours ago
if (x == 0) {
return y;
}
y += 25*x;
return y;
and skipping the if just makes the function shorter and simpler, while also not involving the CPU branch prediction. Another one that doesn't necessarily skip all branching but at least drops one - and more importantly makes the code simpler and easy to verify, is removing the if statement in code like if (count == 0) {
return;
}
for (int i = 0; i != count; i++) {
puts("hello");
}GuB-42 10 hours ago
In the first case, the compiler removes the first if/return
In the second case, if you don't have the first if/return the compiler will add it. That's because it will actually convert your loop into a do/while, with the test in the end, because it is more efficient. But it has to handle the count == 0 special case first, so it will do that early return even if it is not explicitly there.
That's the kind of optimization modern compilers are good at.
cestith 16 hours ago
metabagel 16 hours ago
=====
Should you go branchless?
Most of the time, no. Branchless code is harder to read and easier to get wrong. Besides, compilers know a lot of tricks and already do a lot of this work for us.
Only when a profiler points at a hot loop, and the loop contains a branch on unpredictable data this technique can pay off big.
corps_and_code 16 hours ago
if (thingThatIsTrue):
// a bunch of logic here...
else: // different logic here...
they mean:if (thingThatIsTrue):
return doThisWhenTrue()
return dothisWhenFalse()Just a simple example. I'm not sure if this is what you consider "obfuscating" the branches. Logically the same, but a bit more linear to understand?
Edit: I am bad at formatting comments here.
taink 15 hours ago
Example:
No space before start of line.
One space before start of line.
Two spaces before start of line.
Thus, you can put multiple lines of code with indentation as well as long as you put two spaces at the start of the line:int main() { return 0; }
int main() {
return 0;
}
See https://news.ycombinator.com/formatdoccorps_and_code 14 hours ago
cestith 16 hours ago
It's not applicable to every situation, but one way to do this is some very basic fuzzy logic. You do a little math and then either choose a single branch at the end, or sometimes avoid a branch altogether. https://www.geeksforgeeks.org/artificial-intelligence/fuzzy-...
Another way to avoid some branches is to have specialized routines, maybe with multiple dispatch, rather than more general methods with a bunch of checks within them for slightly different situations.
A classic performance hack for critical sections is loop unrolling.
bryanrasmussen 16 hours ago
if Val === "A" then Do funcA() else if Val === "B" then
and so forth for lots of values, or using a switch statement or similar branching instead of
Object functions = { "A": funcA() {does what funcA does}, "B": funcB() {does what funcB does} etc. etc.
}
runnableFunction = functions[val]; runnableFunction();
Actually writing it I remember now someone who did this, a junior who had to update a validation function for XML invoices based on their root namespaces, which there could be a large number of these, and so she wrote out
switch namespace == "somenamespace" { validatingscheme = "someschema"; doPreliminaryFunctionToDetermineifshouldvalidate(); }
I can't remember all the details as this was almost 20 years ago, however while it was true that one branched on the schema, it made much more sense to look up what one was supposed to do based on the rule for branching and then just execute that one action rather than writing a bunch of branching logic.
So to make it more concrete: Once branching rules becomes sufficiently complex prefer query for what you should do rather than branching
on edit: note again, not real code, but should be understandable and translatable into real code to understand what is being said easily enough.
on 2nd edit: this is also just basically one of the things I prefer instead of getting a lot of branching logic. I have never seen any stats on any benefit to this model than just having a bunch of branching statements, but I feel that the benefit is there nonetheless.
NegativeLatency 16 hours ago
Like imagine you have a few different classes of things A,B,C so instead of checking if the thing you're handling is an A,B,C you have like a shared interface across all and can call Thing.do_it or whatever.
Still branching conditionally but it's passing it off to language features instead of code you have to write.
owebmaster 15 hours ago
hermitdev 15 hours ago
A trivial example is actually written with a branch in C/C++, but relies on compiler optimizations to kick in. If you compile a ternary operator in C/C++ (and probably rust, C# and other languages) such as in:
int min_branchless(int a, int b) {
return a < b ? a : b; // Often emits cmov with -O2
}
With gcc/clang a -O2, one would expect the compiler to emit the following assembly: cmp edi, esi
cmovle eax, edi ; select a if a <= b
ret
There's numerical tricks for other operations/comparisons, and compilers know a lot of them. But, I just suggest compiling your code and configuring your compiler to emit the generated assembly with references to the code it was generated from (you should be able to get it to emit source line references in the assembly). You'll likely be surprised at the optimizations applied at -02, and utterly confused by what you find at -03.edit: Also, it doesn't mean to never branch, but to minimize branching, especially in tight loops. Branch outside loops, not inside, for instance.
e.g. don't do:
for (...) {
if (condition independent of loop variable) {
...
} else {
...
}
}
do: if (condition independent of loop variable) {
for (...) {
...
}
} else {
for (...) {
...
}
}1718627440 13 hours ago
tialaramex 8 hours ago
If you want to tell the Rust compiler that you're certain a branch predictor can't help here [be very sure, most often humans are wrong which is why historically these "I know better than the branch predictor" features get ignored by optimisers] you can core::hint::select_unpredictable(condition, a, b) rather than using a dedicated operator.
† That's not its actual name, some languages have an operator with three operands which does something else, such as fused multiply-add so in a multi-lingual context better to say explicitly you mean the ternary conditional operator.
a_e_k 3 hours ago
vector conditionmask = <some computation...>; // E.g., 11111111 00000000 00000000 11111111
vector truebranch = <some computation...>;
vector falsebranch = <some computation...>;
vector result = (truebranch & conditionmask) | (falsebranch & ~conditionmask);
where each lane of the conditionmask has either all bits set or all bits clear, depending on the outcome of the conditional test for that lane.The processor obviously does execute both branches here, so there's going to be wasted work. But since it's just a linear sequence of operations it can often schedule them independently and run them out-of-order and in parallel. And of course, if there's any shared computation between the two branches, the compiler can do common subexpression elimination.
That said, that sort of approach where you go ahead and do both and then blend them was definitely the kind of optimization where you'd want to profile rather than doing it blindly. But it was a pretty common thing to do when hand-vectorizing code. (Thankfully, auto-vectorizers are pretty good at doing this sort of optimization for you these days. It's been a very long time now since I've had to hand-write vector intrinsics.)
BeetleB 14 hours ago
A common pattern in an old C++ job I had: People writing for loops, coupled with if conditionals, for things that could just be done by chaining functions in the algorithm library.
Don't do a for loop, check for a condition, and break. Use find_if.
reaperducer 16 hours ago
Or stupid, like all those vloggers posting "ZOMG! Go all in with these secret hidden weird trick iPhone life hacks to level up!" that are just regurgitating what's in the manual.
As we used to say, RTFM: https://support.apple.com/en-us/docs/iphone
cestith 16 hours ago
metabagel 16 hours ago
lscharen 16 hours ago
total = calculateOrderTotal(user.order);
if (user.isPremiumMember) {
total = total * 0.9; // 10% discount
versus total = calculateOrderTotal(user.order);
discount = calculateDiscount(user); // Returns 0.9 or 1.0
total = total * discount;metabagel 16 hours ago
total = calculateOrderTotal(user.order);
total = total * user.discount;1718627440 12 hours ago
total = calculateOrderTotal(user.order);
total *= user.discount;
or: return
calculateOrderTotal(user.order)
* user.discount;Narishma 15 hours ago
1718627440 12 hours ago
return 1 - user.isPremiumMember * 0.1;
would also cut it.thornewolf 13 hours ago
v = setup()
if v == 1:
side_effect_1()
elif v > 1:
side_effect_1()
side_effect_2(v)
else:
raise Exception()
then we can "refactor" v = setup()
if v < 1:
raise Exception()
side_effect_1()
if v > 1:
side_effect_2(v)
i know that this might seem "dumb" that the code was ever setup the first way but code can grow into that shape pretty easily. this refactor "removes" the v==1 branch. this new code also follows the "early return" pattern, which improves readability.happytoexplain 16 hours ago
I have always felt like my bar for publishing something (even just to internal wikis/channels) is too high due to being overly self-conscious. I think we should try not to validate that feeling by implying that there is a non-negligible number of readers who will think you have a personality flaw because you wrote down your personal collection of tips in a public place, or that those people deserve consideration in the first place.
There is no such thing as "the things everybody knows". There are just too many things. Even a list of basic tips is probably going to contain one thing I didn't know or perhaps forgot. Write-ups like this are where most of my practical knowledge comes from, not RTFM (which I do).
wiredfool 16 hours ago
PennRobotics 9 minutes ago
My "find" is almost always
tree -if | grep "<whatever-pattern>$" | head -1
head, of course, being optionalThe tradeoff is needing to learn regex, which is not any easier to learn than find arguments.
thebelal 14 hours ago
IsTom 16 hours ago
laweijfmvo 14 hours ago
similar to ripgrep, though, fd is a modern replacement that’s a bit friendlier to use.
jimmaswell 7 hours ago
lucasoshiro 13 hours ago
And I don't think that's a good thing. Especially because AI coding agents use it a lot. They only need to hallucinate a little to destroy your filesystem.
1718627440 12 hours ago
It's essentially like the SQL SELECT expression.
deathanatos 5 hours ago
find -name '*.md' -and -not -type d
Of course, then it becomes more obvious why there are parens, why those parens must be escaped for the shell, etc. E.g., find '(' -name '*.md' -and -not -type d ')' -or '(' [...] ')'
I think once someone groks the nature of the expression args, then find becomes easier to start working with.The most messed up part in my mind though is that while most things in find are clearly helping the expression towards its goal of "true" or "false" on whether to include the file or not in the results, some, like -prune or -exec do so but with side-effects. And since they're usually invoked primarily for their side-effect, it isn't immediately obvious that they even return a value, or are participating in the expression itself. (-prune is true, and -exec depends.) And this is where it becomes important that `find`'s -and & -or are short-circuiting, too. (In a purely logical expression, it wouldn't really matter except as an optimization.)
People also sometimes omit -and, which I'm not a huge fan of the legibility of. (But using -and makes it not POSIX; you can do -a but ew. which brings me to the last bit…)
macOS: the find there requires the starting-point arg; so my examples above, on macOS, would all need to be,
find . [expression args...]
… which is lame. Brew install GNU find and be done with that.While I agree with globbing (or fd) for interactive use, I think for scripting I'd still say "you might want find"; there are limits to arg list lengths (see xargs) that (esp. recursive) globs can exceed; unless you know you'll never glob the world, find might be appropriate. Also:
echo *nope*
Globs will betray you on the zero-match case. (`man bash` & cf. `nullglob`.)asphodele 5 hours ago
bash: Ctrl-L to clear the screen
VSCodium: Shift+Alt+[arrows|mouse click] to select a rectangular block
scp for moving files (instead of ftp)
imp0cat 4 hours ago
Both rsync -avz /path/to/file user@server:/another/path/to/ or rsync -avz /path/to/file/ user@server:/another/path/to/file
Will create directory named /another/path/to/file which will contain all contents of the original directory (/path/to/file/*).
Basically, if you include the trailing slash in the source path, only contents of the directory will be copied (useful when you need to rename it).
rsync -avz path/to/old_dir/ user@server:/path/to/new_dir
If you omit the trailing slash in the source path, rsync will create the target directory for you. See man rsync for more info.urxvtcd 35 minutes ago
Ctrl-l to clear the screen, Ctrl-p to select previous command, Ctrl-j to enter it again. I don't even use Enter key when in terminal anymore.
When you want to pause entering a command for a moment do Ctrl-a to go to the start of the line, and type # to comment out. Then Ctrl-j. You can return to that later with Ctrl-p, then Ctrl-a again and Ctrl-d to remove that comment.
To edit complex commands you might want to use Alt-e to enter $EDITOR.
jonstaab 16 hours ago
AirMax98 14 hours ago