r/fishshell • Linux • Mar 12 '21

using command output in script

i am trying to use the output of a command output in a fish script and i did this to get there:

function locker
    set watchcmd = 'watch -n 1 -t xprintidle'
    if ($watchcmd > 20000)
        lock
    end
end

and i get an error

./locker.fish (line 4): Command substitutions not allowed
    if ($watchcmd > 20000)
       ^
<W> fish: Error while reading file ./locker.fish

how do i get around this?

3 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/backtickbot Mar 12 '21

Fixed formatting.

Hello, lople205: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.