Skip to content

Instantly share code, notes, and snippets.

@drewthorp
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save drewthorp/d8e5d888be72244b8d8a to your computer and use it in GitHub Desktop.

Select an option

Save drewthorp/d8e5d888be72244b8d8a to your computer and use it in GitHub Desktop.
A fish shell function that emits an event when the current directory changes. As of version 2.1.1, function that capture events do not seem to work as autoloading functions, so the easiest thing is to place this in config.fish. As this uses the fish_prompt event, the change of directory will only be notes when a prompt is displayed. It would be …
set -xg FS_CURRENT_DIR ""
function fs_change_directory -e fish_prompt
set -l this_dir (PWD)
if [ $this_dir != $FS_CURRENT_DIR ]
set -xg FS_CURRENT_DIR (pwd)
emit directory_changed
end
end
function fs_change_directory --on-variable PWD
emit directory_changed
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment