Simplified it in https://github.com/haarts/fish-shell/commit/73fc3fd280e8e81127d40700f899fe33e53c772b