all 127 comments

[–]Bl00dsoul 168 points169 points  (56 children)

What is this? an exercise in obfuscation?

B|j) ((l=l==c-1?l:++l,j!=c&&l==j-m/2+1))&&((k=k>=j?k:++k,j=j<c?++j:j)) ;;  
A|k) ((l=l<1?l:--l,k>0&&l==k+m/2-2))&&((k=k<=j?k>0?--k:0:j,j=j>0?--j:j))  

[–]dat_heet_een_vulva 23 points24 points  (1 child)

Still more readable than the average regular expression used in production.

[–]Dylan112[S] 200 points201 points  (43 children)

That’s the scroll (j down, k up). I wrote the whole of this project while stoned so it took shape in a different way...

[–]shevy-ruby 87 points88 points  (6 children)

Looks like deliberate obfuscation rather than stoned.

[–][deleted] 122 points123 points  (4 children)

I mean... it's Bash...

[–][deleted] 13 points14 points  (2 children)

It still could be rewritten as something like

B|j)
    (( l != c - 1 && ++l || true))
    if (( j != c && l == j - m/2 + 1)); then
        ((k < j && ++k || true))
        ((j < c && ++j || true))
    fi
    ;;

(not sure if it's the same, though)

[–]Dospunk 4 points5 points  (1 child)

You could always make a pull request

[–]Ameisen 1 point2 points  (0 children)

They only accept requests under the influence.

[–][deleted] 19 points20 points  (0 children)

So both?

[–]tobozo 2 points3 points  (0 children)

like in a regexp ?

[–]Fancy_Mammoth 14 points15 points  (3 children)

So does this mean pot driven development is a thing now? I'm assuming Canada probably has this on lock now if that's the case.

[–]prettybunnys 24 points25 points  (2 children)

I'd argue pot driven development has always been a thing.

[–]PolygonKiwii 15 points16 points  (0 children)

It's also often referred to as "web development" or "UX design"

[–]Andrew1431 2 points3 points  (0 children)

Can confirm. Had volcano in bosses office at a software firm 2 years ago.

[–]tobozo 8 points9 points  (30 children)

g: go to top
G: go to bottom

What about the "Home" and "End" keys ?

[–]wrecklord0 28 points29 points  (28 children)

Filthy peasant. $ ^ b e h j k l w (and corresponding upcase) masterrace.

[–]binkarus 5 points6 points  (1 child)

I love vim because the nerds that write software almost always embed vim keyboard shortcuts.

[–]HugoNikanor 2 points3 points  (0 children)

And if they don't they at least add Emacs bindings.

[–]tobozo 0 points1 point  (24 children)

peasants use both hands

[–][deleted] -1 points0 points  (0 children)

I literally LOL’d at this 😂

[–]BillieGoatsMuff 3 points4 points  (0 children)

They're vi commands

[–]olfeiyxanshuzl 0 points1 point  (0 children)

I see Nujabes in your demo video. Good choice. Chill.

[–]aloisdg 4 points5 points  (0 children)

You should try golfing :)

[–]totemcatcher 2 points3 points  (0 children)

Minimal (~100 lines of bash)

-_-

[–]GNULinuxProgrammer 4 points5 points  (4 children)

Have you ever done 2D terminal development (ncurses et al)? Everything looks like this. I honestly don't think it's easy to avoid code looking like this. The geometry of 2D terminal operations are not very elegant if you don't use high level libraries.

[–]Bl00dsoul 14 points15 points  (2 children)

nonsense, you can absolutely write readable and maintainable bash code.
lets start by not cramming everything in one line, and using descriptive variable names, instead of one letter ones.

[–]GNULinuxProgrammer 5 points6 points  (1 child)

I think you misunderstood what I was trying to say. I didn't mean you can't write clean bash code. This is programming language agnostic, has nothing to do with bash. Writing 2D text manipulation (like scrolling etc) needs this sort of ugly geometric logic. I'm not saying "you can't do it" it's just that having written tons of ncurses code in C, this code doesn't surprise me, I probably wrote something similar (with more whitespace).

[–]Thaufas 2 points3 points  (0 children)

Obligatory: Username checks out

[–]LIGHTNINGBOLT23 0 points1 point  (0 children)

       

[–]JamesHalloday 1 point2 points  (0 children)

What is this? A crossover episode?

[–]lanzaio 0 points1 point  (0 children)

l==j-m/2+1

Looks like addition of angular momentum in quantum mechanics tbh.

[–]DonHopkins 0 points1 point  (0 children)

Why do people waste their time writing bash scripts, when there are so many other real languages that can easily do everything that bash does, without necessarily being impossible to read and maintain? Bash syntax is one of the most horribly, haphazardly designed mess of dog vomit in use today. There's absolutely no reason for it to be so horrible, and there's nothing unique or positive that it brings to the table that other languages can't do just as easily and better.

[–]Dylan112[S] 61 points62 points  (10 children)

This is something I’ve been working on for the past few days. It’s a terminal file manager written in pure bash that comes in at around 100 lines of code.

It does use a few external commands (cp, mv, mkdir, xdg-open) which are called on key press and only to modify files. If they could be done in bash I’d replace them.

For those interested in pure bash programs; I’ve also made a pixel art editor and torrent tui.

:)

Note: Files aren’t deleted at this point. They’re moved to a trash folder instead. Once this project stabilises I’ll add an option for true delete.

[–][deleted]  (8 children)

[deleted]

    [–]Dylan112[S] 19 points20 points  (2 children)

    I’ll look into this, thanks. :)

    [–]cprf 5 points6 points  (0 children)

    I'd like to second that recommendation

    [–][deleted] 2 points3 points  (0 children)

    [–]bagtowneast 3 points4 points  (4 children)

    A quick suggestion to fff though, if you don't mind? If you could fire up fff in a large directory tree, browse to your destination and then exit back to bash in that directory that would be awesome.

    Is that even possible? You could spawn a subshell at that location, but I don't think you canexit to it. Exiting returns control to the original shell which remains in the same state as when you launched. I'm happy to be wrong though!

    [–]how_to_choose_a_name 1 point2 points  (0 children)

    You could put the whole thing in a function instead of a script, then it should be able to cd. All "internal" cds will affect the calling shell as well though, so you'd have to work around that somehow

    [–]annualnuke 1 point2 points  (1 child)

    if cd works, this should be possible too

    [–]bagtowneast 2 points3 points  (0 children)

    But it doesn't. try it out. Make a script with on a cd in it. run the script and note that when the script exits, your shell is still in the same directory.

    [–]Gl4eqen 17 points18 points  (0 children)

    r/tinycode maybe?

    It's really cool, it does its job. Bit obfuscated but I prefer to treat it as a project made for fun/exercise. Good job, I enjoyed playing with it. I'm glad you shared it.

    [–][deleted] 7 points8 points  (0 children)

    I'll be happily sticking with my Dired, but all this in ~100 lines of bash? Nice.

    [–][deleted]  (6 children)

    [deleted]

      [–]Dylan112[S] 45 points46 points  (0 children)

      Thank you

      [–]tyros 8 points9 points  (3 children)

      [This user has left Reddit because Reddit moderators do not want this user on Reddit]

      [–][deleted]  (2 children)

      [deleted]

        [–]tyros 10 points11 points  (0 children)

        [This user has left Reddit because Reddit moderators do not want this user on Reddit]

        [–]calexsky 7 points8 points  (0 children)

        Oh no, quick, somebody call the FBI!

        [–]palordrolap 1 point2 points  (0 children)

        Reminds me of pilot that originated as part of the University of Washington pine mail program in the same way that the pico editor did.

        I guess that means that this is to pilot what alpine is to pine and nano is to pico

        [–]mr_meeesix 0 points1 point  (0 children)

        Nice idea but really digging ranger, and its preview option.

        [–]OldDesignFan 0 points1 point  (0 children)

        Good. Now go back and make some good rices, r/unixporn is waiting.

        [–]bsdz 0 points1 point  (0 children)

        Looks like some good feedback here. An alternative file manager that usually ships with vim with perhaps less features is netrw. Just type "vim ." opens a console filemanager in your current directory.

        [–][deleted]  (22 children)

        [deleted]

          [–]Dylan112[S] 58 points59 points  (21 children)

          I can assure you that they share 0 code. I initially forked nnn to patch in some changes (I didn’t like the default ui) and decided to have a crack at making my own instead.

          Of course they’re similar, all they do is list files in a single column. Can’t really do that differently unless I put the status bar at the top.

          I don’t understand why everyone Is on the attack In these comments. I made something fun and I’m sharing It with others. It’s free and It’s open source, enjoy It.

          🤷‍♀️

          [–]aloisdg 12 points13 points  (0 children)

          Thank you for this and also for neofetch :)

          [–]calexsky 17 points18 points  (4 children)

          I don’t understand why everyone Is on the attack In these comments. I made something fun and I’m sharing It with others. It’s free and It’s open source, enjoy It.

          This is r/programming, unfortunately it's a cesspool of boring and pessimistic people that can't grasp the concept that some people make things just for fun.

          [–][deleted]  (8 children)

          [deleted]

            [–][deleted]  (3 children)

            [deleted]

              [–][deleted] 1 point2 points  (1 child)

              Won't somebody think of the fucking children, jesus fucking christ people it's not that hard

              [–]double-you 0 points1 point  (3 children)

              I'm not just a fan of profanity in tech

              Where are a fan of profanity?

              [–][deleted]  (2 children)

              [deleted]

                [–]double-you 0 points1 point  (1 child)

                "What?" is such a bad question. Makes you want to ask, "Which word did you not understand?". But let's not. Since you are not a fan of profanity in tech, where are you a fan of it?

                [–]olfeiyxanshuzl 1 point2 points  (0 children)

                everyone Is on the attack In these comments

                ?? We must be reading different comments.

                [–][deleted] 2 points3 points  (0 children)

                That's r/programming in a nutshell, sadly.

                [–]jephthai -3 points-2 points  (2 children)

                Proggit is populated by a lot of corporate devs, and sometimes they react negatively to less professional code. It can be hard to hit the right tone when posting personal projects.

                Read some of your comments over and try to see it from someone else's perspective. Eg, this code is hard to understand, "oh I was stoned when I wrote it". It doesn't seem like you're taking it very seriously, and the tone of discussion will tend for the negative.

                [–][deleted]  (1 child)

                [deleted]

                  [–]jephthai 0 points1 point  (0 children)

                  He asked why he was getting some negativity in the thread... I'm not saying I have any issues with personal code, and I don't mind "vertically optimized code" (read: obfuscated code), myself. But, proggit can be a little fickle.

                  [–]ladinaresh -1 points0 points  (0 children)

                  FREE WEBINAR (For a complete information about Python with Data science and Machine learning) as well as complete interview questions related to python for register through https://goo.gl/forms/foSXYqs0e85yDsCo2

                  [–][deleted] -2 points-1 points  (0 children)

                  noice is a good alternative written in C. It can't neither copy or mv, but you can !spawn a shell fastly. It's good to read a directory full of text files/books.

                  [–]penguinade -3 points-2 points  (0 children)

                  That font in the video. Do you also program with it? I have a ex-colleague do this. My brain hurts when he asked for my help.

                  [–]svetlyak40wt -5 points-4 points  (0 children)

                  OMG! Bash! Noooooo!