5 ms·
I just make bash functions in my dotfiles for use cases like these, particularly good CLI arg combinations from Stack Overflow answers, etc. Example: # 20
by tedmiston 5y ago
I just make bash functions in my dotfiles for use cases like these, particularly good CLI arg combinations from Stack Overflow answers, etc.
Example:
# 2022-02-07
# because `poetry show --outdated` includes *all* packages (!), not just top-level dependencies
function poetry-show-outdated {
poetry show --outdated | grep --file=<(poetry show --tree | grep '^\w' | cut -d' ' -f1)
}
Or:
function disk-usage-summary () {
# output high-level disk usage stats
set -x
du --human-readable --summarize
du --human-readable --max-depth=1
df --human-readable --total
set +x
}
- chockchocschoir 5y agoThat actually runs the commands right? How do you deal with commands that perform some action that maybe couldn't be reverted easily?
- tedmiston 5y agoCorrect. If I don't necessarily want to run all of the commands, I make a "do-nothing script" [1][2] that just echoes them out instead. I don't have a generalized example of undo / redo in bash commands, since I don't believe it's possible, but for example, if I'm running a destructive command, I prefer to run the dry run version first, then have a confirmation prompt [3] before running the destructive action. [1]: https://news.ycombinator.com/item?id=20495739 https://news.ycombinator.com/item?id=20495739 [2]: https://news.ycombinator.com/item?id=29083367 https://news.ycombinator.com/item?id=29083367 [3]: https://stackoverflow.com/q/1885525/149428 https://stackoverflow.com/q/1885525/149428