3 ms·
Ok, go ahead and port all 200 of these scripts to Python please: https://github.com/shawwn/scrap https://github.com/shawwn/scrap PR's welcome. ;) Python makes
by sillysaurusx 7y ago
Ok, go ahead and port all 200 of these scripts to Python please: https://github.com/shawwn/scrap https://github.com/shawwn/scrap
PR's welcome. ;)
Python makes sense for scripts that need good argument parsing, or complicated intermediate input processing. But it's pretty annoying to get a shell pipeline working in Python. `foo | bar | baz` is about 15 characters in bash.
Here's an example. I use `llbranch` all the time: https://github.com/shawwn/scrap/blob/master/llbranch https://github.com/shawwn/scrap/blob/master/llbranch
It lists all branches in a project. It's nicely colorized. What would the equivalent Python be? Who knows, but it'd be much longer.
- kohtatsu 7y agoCool repo, but the example is lame because a shell, or a git alias would do just fine. A shell script that consists of a one-line exec isn't what people concerned about. FWIW I'm a 99.9% POSIX masochist (probably closer to 4N)
- kohtatsu 7y agoLooks like a lot of your scripts couldbe aliases, I store mine in ~/.aliases, and slightly more complicated things (e.g. take arguments) in ~/.functions, and source both those files from bashrc. I have maybe 3 standalone shell scripts in my PATH, despite writing thousands of lines of shell.
- ben509 7y agoI had a mess of shell functions. It is nice that they run more quickly, but I don't have any shell commands that need to run that often. What moved me to putting them in a bin directory was that it's just easier to edit a standalone script.
- kohtatsu 7y agoWrite a shell script to concat them into a single file to source ;)
- mfontani 7y agoI've moved from aliases to scripts as I can't seem to have found the (if any exists...) way to ensure aliases can be used from within vim's ":!..." or ":'<,'>!...", and as I often find myself wanting to either execute something while I'm amending code, or wanting to filter text with a purpose-built command, I end up writing (sometimes very short!) shell scripts.
- ddebernardy 7y agoCorrect me if my first impression was incorrect, but scanning through your scripts they all seemed like sub-kilobyte one-liners. Which, yeah, just use Shell for those and you'll be fine. To my mind, the parent post was referring to lengthier, more complicated scripts. Speaking as one who wrote and routinely maintained such scripts at one point, I cannot agree more with the sentiment that most if not all of them could and should have been written in Python or Ruby or some other scripting language instead.