5 ms·
I use fishshell, and I've gotten in the habit of creating a function called `t` to run tests. This function captures whatever test command I'm currently using.
by jkubicek 6y ago
I use fishshell, and I've gotten in the habit of creating a function called `t` to run tests. This function captures whatever test command I'm currently using. Just test one file, run one test case, use a debugger, capture coverage, etc. I don't save the function, so it doesn't persist across Terminal sessions. If I need to change how I'm running tests, I update the function.
It's a small, but noticeable improvement over the way I was working before, either up-arrowing until I found the last time I ran tests, or typing, `pytest...` and letting autocomplete figure out what I was doing previously.
edit: So yes, I am also a big fan of helping to enforce consistency by scripting even the small things.
- ch4s3 6y agoWould you mind sharing a gist of that function?
- dfinninger 6y agoI’m assuming they mean something like: t() { bazel test //some/specific/thing/... # or pytest, maven, sbt, etc etc } Add in whatever option you want to the test command there. Then you just press “t” and it runs your tests.
- Felk 6y ago> either up-arrowing until I found the last time I ran tests just as a substitute for up-arrowing, have you tried ctrl-r/reverse-i-search? (if that's a thing in fishshell) edit: I see wodenokoto already mentioned this workflow in another comment
- simongr3dal 6y agoin fish you can type some of the command and arrow-up. It will show only commands containing that substring.
- frutiger 6y agoSo does libreadline (and therefore bash). The following in ~/.inputrc does the trick for vi mode users: k: history-search-backward j: history-search-forward There is an equivalent for emacs mode.
- jonfw 6y agoCheck out FZF for fuzzy finding through your command history in this manner- it is absolutely the superior way to search command history
- Macha 6y agoIf you type before up arrowing this is what the up arrow does in fish
- wheybags 6y agoI wrote a small python script, that I alias in my shell to "b" (for build). When I run it in a given directory, it prompts me for a command, if it doesn't have one already saved. Subsequent runs just run the saved command, but it can save a different command for each folder. I use it to clear and remake my build directory using cmake on my c++ projects, with the various compile options saved in as well. It's basically a persistent version of what you describe. Here's the script, if you're interested. It's not super complex. https://github.com/wheybags/stuff/blob/master/build-dir-command.py https://github.com/wheybags/stuff/blob/master/build-dir-comm...
- bauerd 6y agoHave a function similiar to this, reruns the last test command function retest set --local cmd (history | grep -v history | grep -Em1 "((bundle exec)?rspec|go test|jest)") echo "Rerunning `$cmd`" eval $cmd end