Skip to content

Instantly share code, notes, and snippets.

@judy2k
Created September 14, 2024 10:31
Show Gist options
  • Save judy2k/6c85366803e93c19c677d49e81544c65 to your computer and use it in GitHub Desktop.
Save judy2k/6c85366803e93c19c677d49e81544c65 to your computer and use it in GitHub Desktop.
Fish Shell: Expand 'run' to an appropriate 'run' command, depending on the files in the current directory.
function _expand_run
-d "Expand the 'run' abbreviation into a project-specific run command.";
if test -e Justfile;
echo just run
else if test -e Makefile;
echo make run
else if test -e Cargo.toml
echo cargo run
else if test -e package.json
echo npm run dev
end
end
abbr --add run --function _expand_run;
abbr --add r --function _expand_run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment