Skip to main content
cleaned up
Source Link

Yes, I did it! It does the job, but I still wish fish had something native.

Define my function: I choose the name blotch so it doesn't interfere with bash's watch.

function hblotch
    hello# 2018-10-10
end    # 

Build my watch thingy:

function    # This is like the watch command of bash,
    set# argbut $argvre-implemented in fish.
    # 
    # It takes two arguments:
    #   n: the interval in seconds
    #   fun: a fish function
    # 
    # Therefore, it is always used as:
    # 
    #   blotch n fun
    # 
    # Take note that you should start fish with
    # 
    #   sudo fish
    #   
    # before doing anything with blotch that
    # requires administrator privileges.
    
    set time (string split " " -- $arg$argv)[1]
    set comcommand (string split " " -- $arg$argv)[2]
    while true
        sleep $time
        eval $com$command
    end
end

SaveAnd save the thingfunction for futurelater use:.

funcsave watch

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!blotch

It does what I want to do. It's fine. :)

Yes, I did it! It does the job, but I still wish fish had something native.

Define my function:

function h
    hello
end

Build my watch thingy:

function watch
    set arg $argv
    set time (string split " " -- $arg)[1]
    set com (string split " " -- $arg)[2]
    while true
        sleep $time
        eval $com
    end
end

Save the thing for future use:

funcsave watch

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!

It does what I want to do. It's fine. :)

Yes, I did it! It does the job, but I still wish fish had something native. I choose the name blotch so it doesn't interfere with bash's watch.

function blotch
    # 2018-10-10
    # 
    # This is like the watch command of bash,
    # but re-implemented in fish.
    # 
    # It takes two arguments:
    #   n: the interval in seconds
    #   fun: a fish function
    # 
    # Therefore, it is always used as:
    # 
    #   blotch n fun
    # 
    # Take note that you should start fish with
    # 
    #   sudo fish
    #   
    # before doing anything with blotch that
    # requires administrator privileges.
    
    set time (string split " " -- $argv)[1]
    set command (string split " " -- $argv)[2]
    while true
        sleep $time
        eval $command
    end
end

And save the function for later use.

funcsave blotch
added 63 characters in body
Source Link

Yes, I did it! It does the job, but I still wish fish had something native.

Define my function:

function h
    hello
end

Build my watch thingy:

function watch
    set arg $argv
    set time (string split " " -- $arg)[1]
    set com (string split " " -- $arg)[2]
    while true
        sleep $time
        eval $com
    end
end

Save the thing for future use:

funcsave watch

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!

It does what I want to do. It's fine. :)

Yes, I did it!

Define my function:

function h
    hello
end

Build my watch thingy:

function watch
    set arg $argv
    set time (string split " " -- $arg)[1]
    set com (string split " " -- $arg)[2]
    while true
        sleep $time
        eval $com
    end
end

Save the thing for future use:

funcsave watch

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!

It does what I want to do. It's fine. :)

Yes, I did it! It does the job, but I still wish fish had something native.

Define my function:

function h
    hello
end

Build my watch thingy:

function watch
    set arg $argv
    set time (string split " " -- $arg)[1]
    set com (string split " " -- $arg)[2]
    while true
        sleep $time
        eval $com
    end
end

Save the thing for future use:

funcsave watch

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!

It does what I want to do. It's fine. :)

added 53 characters in body
Source Link

Yes, I did it!

Define my function:

function h
    hello
end

Build my watch thingy:

function watch
    set arg $argv
    set time (string split " " -- $arg)[1]
    set com (string split " " -- $arg)[2]
    while true
        sleep $time
        eval $com
    end
end

Save the thing for future use:

funcsave watch

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!

It does what I want to do. It's fine. :)

Yes, I did it!

Define my function:

function h
    hello
end

Build my watch thingy:

function watch
    set arg $argv
    set time (string split " " -- $arg)[1]
    set com (string split " " -- $arg)[2]
    while true
        sleep $time
        eval $com
    end
end

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!

Yes, I did it!

Define my function:

function h
    hello
end

Build my watch thingy:

function watch
    set arg $argv
    set time (string split " " -- $arg)[1]
    set com (string split " " -- $arg)[2]
    while true
        sleep $time
        eval $com
    end
end

Save the thing for future use:

funcsave watch

Begin the fun:

david@f5 ~> watch 3 hello
Hello, world!
Hello, world!
Hello, world!

It does what I want to do. It's fine. :)

Source Link
Loading