Search code examples
shellfish

add a number in fish script


I want to have a function that gets the number of lines of output from a command and adds one to it. So far I have this:

function add1
    set num (tmux list-sessions | wc -l)
    echo $num
end

Now how do I add 1 to $num? (or while I'm assigning the variable)


Solution

  • See the math command in the user documentation:

    set num (math $num + 1)