DEV Community

Cover image for 10 tiny helper scripts for devs!

10 tiny helper scripts for devs!

Ben Winding on August 24, 2020

Notes This is a collection of tiny scripts that you can execute through the terminal. These are designed for Ubuntu (with zsh), but may...
Collapse
 
moopet profile image
Ben Sinclair • Edited

A few thoughts -

1 might be better named "git-uncommit" because "undo" implies reverting whatever the last action was, not specifically the last commit.

2, 3 and 4 don't need a shebang. They need to be sourced rather than executed else they'll do nothing.

4 doesn't need the function keyword, and has two commands on the same line separated with a semicolon which is not great for readability.

6 and 7 would be better off using $() than backticks.

8 and 9 mix a lot of styles and seems like they could be made more readable by sticking to printf instead of echo and consistently using double-quotes.

8 and 9 rely on the main branch being called "master" which is less and less likely to be the case nowadays. If you're using git-flow, you can use this hack to get the name of the "master" branch:

main_branch=$(git config --local --get gitflow.branch.master)
Enter fullscreen mode Exit fullscreen mode

They also expect certain conventions for other branches such as "unstable" and the principle remote to be called "origin", which is not always the case.

Collapse
 
benwinding profile image
Ben Winding

Thanks Fellow Ben,
Cheers for the feedback, you seem to have some knowledge of shell code, do you have your own library of snippets too? If not you should consider starting a dotfiles git repo 👍
Cheers

Collapse
 
moopet profile image
Ben Sinclair

I have one! And it has a few git tools in it.

I had the same alias as you for "undo" but as a git alias and just updated it to be "uncommit" rather than my rather dumb, "oops" command. I never used "oops" for exactly the reason I put in my comment. I remembered I had it but not what it did and couldn't be bothered to check. Now maybe I will...

github.com/moopet/dotfiles

Thread Thread
 
benwinding profile image
Ben Winding

Thanks for sharing, yeah personally I like to name functions as an extension of the original command e.g; git-uncommit is longer but it's easily discoverable when you're typing git and tab-completion makes it fairly easy to type.

I like your alias alias gti='git' I always mistype that!

Collapse
 
goodidea profile image
Joseph Thomas

love this! I'm on OS X and added the github-open command - i just had to change the last line to open #{repolink}

Also, it took me a minute to figure out that I needed to add these files to my $PATH, a note in the post on how to do this would be helpful for others!

Collapse
 
helderberto profile image
Helder Burato Berto • Edited

Nice tips!

I've some useful things on my dotfiles: github.com/helderburato/dotfiles

Collapse
 
benwinding profile image
Ben Winding

Nice, thanks for sharing. I like the functions you have here:

github.com/helderburato/dotfiles/b...

Especially the find function, looks much simpler 👌

Collapse
 
helderberto profile image
Helder Burato Berto

You're welcome :D

Collapse
 
ephraimduncan profile image
Ephraim Duncan

Someone should make them into an npm package

Collapse
 
benwinding profile image
Ben Winding

See the beauty of making your own scripts (dotfiles) is that you maintain them yourself! Don't have to worry about breaking changes, fixing other peoples issues, it's great!

Collapse
 
ephraimduncan profile image
Ephraim Duncan

Yh, It is

Collapse
 
harrisgeo88 profile image
Harris Geo 👨🏻‍💻

that list is 🔥

Collapse
 
adriangrigore profile image
Adrian Emil Grigore • Edited

If you're into this stuff checkout my projects mkws.sh and adi.tilde.institute. Some are WIP. Feedback is welcomed!