Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Last active December 16, 2021 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongyuwei/e4224347130e8f51415c40e8a1e3a8bd to your computer and use it in GitHub Desktop.
Save dongyuwei/e4224347130e8f51415c40e8a1e3a8bd to your computer and use it in GitHub Desktop.
test event handler of fish shell script
function custom_event_test --on-event test_event
echo 'event hook'
echo event test: $argv
end
emit test_event foo bar
function on_pwd_changed --on-variable PWD
echo 'on_pwd_changed hook'
echo ">>> The current dir is: " $PWD
end
cd ../
cd -
function on_foo_changed --on-variable foo
echo ">>> foo is: " $foo
end
set foo bar
set foo foobarz
#### run it: `fish test_fish_event_handler.fish`
@dongyuwei
Copy link
Author

also see https://github.com/jethrokuan/z/blob/master/conf.d/z.fish#L45

function __z_on_variable_pwd --on-variable PWD
    __z_add
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment