Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add a number in fish script

Tags:

shell

fish

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)

like image 251
user2865156 Avatar asked Sep 14 '14 00:09

user2865156


People also ask

How do you set a variable in a fish shell?

Unlike other shells, fish has no dedicated VARIABLE=VALUE syntax for setting variables. Instead it has an ordinary command: set , which takes a variable name, and then its value.

How do I customize my fish prompt?

To create a custom prompt create a file ~/. config/fish/functions/fish_prompt. fish and fill it with your prompt. Is there a way to save multiple prompts, or add to the list of available prompts that are displayed when you run fish_config?


1 Answers

See the math command in the user documentation:

set num (math $num + 1)
like image 86
Charles Duffy Avatar answered Oct 21 '22 05:10

Charles Duffy