HackerTrans
TopNewTrendsCommentsPastAskShowJobs

rgrau

no profile record

comments

rgrau
·vor 4 Monaten·discuss
aha! I see what you mean, it's indeed a nice option, yep.

Using brackets like this is something I never thought of, and it's probably why it's hard for me to process it, but I can see it provides nice annotation capabilities, and it's a more self-contained style.

Thx for sharing!
rgrau
·vor 4 Monaten·discuss
That's very cool!

To take advantage of the "leading space" one, I have this, to mark some commands that I never want to record:

       unhist () {
         alias $1=" $1"
       }
       unhist unhist
       unhist fzf
       unhist rghist     #custom command that greps .zhistory,...
rgrau
·vor 4 Monaten·discuss
for multiline pipes, it's WAY better to format like

    foo   |
      bar |
      baz 
You don't have to use backquotes, AND, it allows you to comment line by line, because there's no backslash messing with the parser.

I also use a last `|\ncat` so you can delete any line and you don't have to worry about the last line being a bit different than the rest

I created a list of similar tricks in https://github.com/kidd/scripting-field-guide in case anyone wants to take a look
rgrau
·vor 4 Monaten·discuss
A similar trick:

    #!/bin/sh
    $*
that's my `~/bin/noglob` file, so when I call a zsh script from bash that uses `noglob`, it doesn't blow up.
rgrau
·vor 4 Jahren·discuss
Oh, I hadn't noticed that links are not highlighted as such (unless already visited).

Fixed, thanks!
rgrau
·vor 4 Jahren·discuss
Fixed, thanks!
rgrau
·vor 4 Jahren·discuss
> If appropriate, change to the script’s directory close to the start of the script.

> And it’s usually always appropriate.

I wouldn't think so. You don't know where your script will be called from, and many times the parameters to the script are file paths, which are relative to the caller's path. So you usually don't want to do it.

I collected many tips&tricks from my experience with shell scripts that you may also find useful: https://raimonster.com/scripting-field-guide/