Transform Your Scripts With Bash Simple Curses

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 142

  • @PatriceFERLET
    @PatriceFERLET Před 2 lety +274

    Hello. I'm the author of bash simple curses and I'm very glad that you speak about it. That was, originally, a simple script to display a dashboard of several commands. And I decided, years ago, to share it. I'm not very active on the repository for a while but I still accepting pull request and I do, sometimes, some fixes. Thanks a lot for the presentation 👍😊

    • @DarkGladiator
      @DarkGladiator Před 2 lety +9

      Thanks for making it

    • @juancarlosescarti4117
      @juancarlosescarti4117 Před rokem +5

      Is beautiful utility. Clean and easy. Good Job. You know very well bash programming. I think more interact with the user options, like choice example, like dialog menu options or options panel to perform users action.
      Thanks for your job

    • @gonzalooviedo5435
      @gonzalooviedo5435 Před rokem +3

      Amazing man, very useful, I'm thinking in using with my phone connected over ssh to My PI and the PI give me some useful information about my program or services states. Yes definitely a MUST

    • @robsku1
      @robsku1 Před rokem +3

      Awesome - I love your work for both practical reasons and being actually useful, and for other reasons. I just posted two comments (one as a "reply" to the first) that you might want to read, I think you like what I'm saying - and perhaps you might be able to shed some light into what I wrote in my second one. For me my comments show right above yours, for now at least - but that's probably not the case for you, if you want to read them and can't see them right away, it's probably best to use the browsers search finctionality with my username :D And sort the comments from newest to oldest, if you don't already have CZcams set to do so automatically.
      But yeah, I love what you have created - I would love to see it grow, I can see a lot of potential for more. I would love to take this job myself and fork your project, but I have more projects of my own than I can handle already, so...
      Anyways, your work is already awesome as it is, I really appreciate that you've written it, even if this is the final state of it as far as you go; besides, and this is why I wrote "as far as you go", FOSS has the mighty power of "fork" and there's always a change that someone else like me will unleash that power on your project ;)

    • @user-mc8xt1iq7c
      @user-mc8xt1iq7c Před 4 měsíci

      thanks brother! pull requests incoming lol

  • @Finkelfunk
    @Finkelfunk Před 2 lety +24

    Console GUIs are super underrated. I actually wrote a specific highly flexible menu printer in Python that I use in almost every project. I spent a good 6 hours total on that thing but whenever I need to draw up a menu now I can just use this one no problem.

    • @theodorealenas3171
      @theodorealenas3171 Před 2 lety

      I mean it's nice but it requires a terminal. If you want a menu that's not a niche need. There are legit solutions! Dmenu, rofi, that XMonad weird diamond shape and more.
      So I suppose it's a flexible menu but super flexible? What is it that it was a good idea to make it a TUI?

    • @Finkelfunk
      @Finkelfunk Před 2 lety +4

      ​@@theodorealenas3171 Well, super flexible as in I can switch parameters like length and symbols very easily without needing to deep dive into the code again. I have flexible parameters I can input into the function and it just does the stuff I want to do. Mind you, this is not a 900 line script either, it is a simple few lines of code that draw up a nice and simple line of dashes while also being able to accept input text lines I can use to give a title or draw up a selection menu in the center of those dashes, code I can use to draw up a loading bar, stuff like that. Small but handy tools to make applications look nicer in the console, more orderly. It's simple and effective, versatile and I also needed an excuse to practice Python lol

    • @theodorealenas3171
      @theodorealenas3171 Před 2 lety

      @@Finkelfunk well that last bit sold me to be honest. Because I made a GUI python program that shows a full screen battery widget and disappears automatically. And my only excuse is that it's simple and in my hands it's flexible.

    • @Finkelfunk
      @Finkelfunk Před 2 lety +3

      @@theodorealenas3171 Yeah obviously most code you make for your own benefit is probably gonna be useless. Had I designed a UI package I'd have completely done it differently, but as long as it helps me save time to draw up a nice menu there is nothing wrong with that. :)

  • @MrHaomich
    @MrHaomich Před 2 lety +70

    There is also cli tool called "dialog" which allows you to create various ncurses dialogs. So with this two tools combined you could have very nice interactive ncurses interface for bash scripts.

    • @nathanmiddleton1478
      @nathanmiddleton1478 Před 2 lety +3

      *chuckle* that's exactly where I thought he was headed right away since dialog has been around for a few decades.

    • @anon_y_mousse
      @anon_y_mousse Před 2 lety +1

      @@nathanmiddleton1478 Sure, but he hasn't been using Linux as long as us. And you can't expect someone to know everything.

    • @nathanmiddleton1478
      @nathanmiddleton1478 Před 2 lety +4

      @@anon_y_mousse and I was not at all being rude. I chuckle because that's what I expected. It's nice to see different perspectives.

    • @anon_y_mousse
      @anon_y_mousse Před 2 lety

      @@nathanmiddleton1478 I didn't mean to imply that you were, I'm just saying he's likely younger than you or I.

    • @cjbarroso
      @cjbarroso Před 2 lety +1

      @@anon_y_mousse and I

  • @RadioTeal
    @RadioTeal Před 2 lety +42

    Programming can be fun and is a challenge :-) However, fair warning, it can also be a deep rabbit hole!

    • @senjougahara9606
      @senjougahara9606 Před 2 lety

      what do you mean sir?

    • @RadioTeal
      @RadioTeal Před 2 lety +5

      @@senjougahara9606 Simply that it can lead one down a rabbit hole which is not necessarily bad, just speaking from my own experience where I decided to learn C++ first because at the time, that was "the thing" to learn. Lead me to Java, Python, Perl, etc. Now Haskell and Rust. So it is commendable to keep learning, but can become "addictive" as well.

    • @TheSulross
      @TheSulross Před 2 lety +5

      computers are boring unless they're used for programming

    • @herrkrake8106
      @herrkrake8106 Před 2 lety

      @@TheSulross or for porn!

    • @herrkrake8106
      @herrkrake8106 Před 2 lety +4

      "You take the blue pill - the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill - you stay in Wonderland and I show you how deep the rabbit-hole goes."

  • @baneblade__
    @baneblade__ Před 2 lety +16

    Instructions unclear, my terminal is now cursed and is sentient and threatening to murder me

  • @VaughnKottler
    @VaughnKottler Před rokem

    I really appreciate how you don't get random details about Linux (or computers in general) wrong like a lot of folks on CZcams might do if they just wanted to "make a video about a library they tried" - this was genuinely a useful and entertaining video for a career software engineer. Thanks for the effort!

  • @stewpidmoney6634
    @stewpidmoney6634 Před 2 lety +14

    I need a 5 hour bash script tutorial with your tips and tricks

  • @AndersJackson
    @AndersJackson Před 2 lety +1

    /bin /lib etc. and /usr/bin /usr/bin is usually where the distribution put programs, data, programming libraries etc.
    /usr/local/bin /usr/local/lib etc. is where the local system administrator puts programs, data and programming libraries etc. for all users to use. Usually this is in PATH before the other two. So you can override if there are a command with same name installed by the distribution.
    And your own programs you have in ~/bin ~/lib for your own installation. This might need you to add into PATH etc.

  • @speedyfox9080
    @speedyfox9080 Před 2 lety +3

    curses in bash!! I sure want to watch this video

  • @davidh.4944
    @davidh.4944 Před rokem +1

    I see quite a number of scripting improvements that can be made....
    "$(...)" is much preferable to `` in the shell. It is much easier to read, easier to nest, and is posix compliant. Backticks are shell dark-ages mumbo jumbo.
    "cut | sed | cut" ... etc. Multi-process strings like this can almost always be replaced with a single awk or sed instance.
    Using the read builtin to slice the input into multiple variables or an array is also often an option, especially if you just need a single value.
    IFS='"," read -a ut < "{2..6}"
    "`for 'inet in iconfig....`" : Do not process command input with for. Use a "while read" loop instead.
    while read inet ; do ... ; done <

  • @christophejournoud2773
    @christophejournoud2773 Před 2 lety +15

    Hi DT, you can use ncurses with python and certainly a lot of other programming languages

    • @samsungsarsamsungsar7792
      @samsungsarsamsungsar7792 Před 2 lety

      In fact mature C, Fortran etc libraries are legacy for Python, Rust, etc. #Internet4iran

  • @linuxninja
    @linuxninja Před 2 lety +82

    chmod +x is bad for security. use chmod u+x to make it executable only for the owner

    • @youtube.user.1234
      @youtube.user.1234 Před 2 lety +7

      Oh, I didn’t know that. I always used to do chmod +x whenever I want to run a script that I wrote. What is the difference between “chmod u+x” and “chmod +x”

    • @williamwu3457
      @williamwu3457 Před 2 lety +2

      You mean the whole security is based on this execution permission ?

    • @denoww9261
      @denoww9261 Před 2 lety +13

      @@williamwu3457 No, obviously not, but it's just a general good practice.

    • @yash1152
      @yash1152 Před 2 lety

      4:04

    • @samgould8567
      @samgould8567 Před 2 lety +3

      Unless there is a specific security risk in running a script you wrote, 755 is fine. That’s what pretty much everything in /usr/bin uses.

  • @bradleyeverson697
    @bradleyeverson697 Před 2 lety +3

    Hey DT. This is pretty cool. Definitely shows another level and the power of bash script. This simple curses has a conky feel to it. LOL.
    I have created some python script that uses tkinter to create GUI. You can buttons and menus to do some useful things.
    Keep up the great work DT.

  • @TomaszB
    @TomaszB Před 2 měsíci

    It reminds me old Turbo Pascal and Turbo C from Borland and their TUI window system :D

  • @killistan
    @killistan Před 2 lety +1

    Ncurses tutorials are pretty easy to follow. Or, at least, the one I looked at made it pretty easy.

    • @yash1152
      @yash1152 Před 2 lety

      can u share the ones you looked up then?

    • @killistan
      @killistan Před 2 lety +1

      *depending on your system, you might also have to add -ltinfo to the gcc ... -lncurses., to get everything to compile. That wasn't mentioned, unfortunately.

  • @AliensInc.
    @AliensInc. Před 2 lety

    This will be fun to play with, thanks :D
    Love these small utilities you make us know about

  • @IanHaver
    @IanHaver Před 2 lety +3

    One of the best TUI apps is midnight commander (mc)

    • @d.8362
      @d.8362 Před 2 lety +2

      THANK YOU!!! I can't say this enough. Perfect on rpi over ssh for easy navigation and manipulation of anything command line do-able.
      To add to this, for Linux newbies mcedit is a companion text editor with an nurses interface that is much more user friendly than remembering a billion key combinations for vim or the other text editor they always recommend.

  • @Jack-gb2nz
    @Jack-gb2nz Před 2 lety +2

    Hey DT, can you do a video on installing & configuring Calamares installer?

  • @hellobri4n
    @hellobri4n Před 2 lety +3

    What are you using for your terminal theme? I love the Git info on the prompt!

  • @JollyboatBros
    @JollyboatBros Před 2 lety +1

    I'd add web-based / JavaScript as an additional paradigm, it's very useful. (Also Emacs Lisp is similar and can be great for many use cases - living inside a running system with some interface primitives in the same way)

  • @genghiskhan5685
    @genghiskhan5685 Před 2 lety

    First time seeing this channel but lol this guy gives me Professor Messor vibes. Even favors him a bit. Either way good content and I'll stick around to see what I can learn.

  • @robertcooperAZ
    @robertcooperAZ Před 2 měsíci

    I know this video is 2 years young but, I would like to suggest "yad gui" which is based on zenity but with 100s more options.. It is much easier than GTK coding. yad uses many of the gtk widgets and provides an excellet frontend for terminal commands. Requires GTK 3 installed and yad code does not need compiling.

  • @ltxr9973
    @ltxr9973 Před 2 lety

    This is very cool, I need to try this out. I have noticed a few small TUI programs of that style but never knew what library they were based upon. But then again if you wanted to use ncurses you don't have to know C to do so. Just like with wxwidgets, there are bindings for many languages. I think some of the available ones are Python, Java, Perl, PHP and Javascript.

  • @AudioKuroneko
    @AudioKuroneko Před 2 lety +2

    Well explained , and informative!

  • @IvanGarcerant
    @IvanGarcerant Před 2 lety +4

    you need to explore Tcl/Tk. Its syntax reseamble CSH and it provides GUI Widgets.

    • @yash1152
      @yash1152 Před 2 lety

      can you explain a li'l bit more?

    • @IvanGarcerant
      @IvanGarcerant Před 2 lety +1

      @@yash1152 so you mean about Tcl/Tk? Well, Bash is based on ksh. The alternative back then was csh. TCL is a scripting language that follows the csh style. Upon TCL, you can define libraries and extentions. Tk is the most popular extention. It Allis you to code gui applications. All with a fairly simple syntsx.

    • @yash1152
      @yash1152 Před 2 lety +1

      @@IvanGarcerant ohkay. thanks

  • @miriam-english
    @miriam-english Před 2 lety +2

    Interesting. Thanks. I'd like to point out that line 313 of the simple_curse.sh file should probably be commented out. Forcing default text to be white might be fine for a dark theme, but those of us who use a white background on the CLI have the user-text disappear.
    I also noticed another strange effect. My bash scripts usually begin with "#!/bin/sh" with /bin/sh actually being a link to /bin/bash which works for pretty-much everything, but for some reason produces an error in the simple_curses.sh file at line 520:
    simple_curses.sh: line 520: syntax error near unexpected token `

    • @djyotta
      @djyotta Před 2 lety

      It's not weird. On the system you had the error, /bin/sh probably did not link to /bin/bash or if it did, it was a different version of bash or not actually bash. On ubuntu for example, /bin/sh is linked to /bin/dash (yet another shell). They do this because /bin/dash is almost fully compatible with /bin/sh.
      I never start my scripts with #!/bin/sh unless the script is guaranteed to work outside of bash... I strive to make all my scripts compatible if I can as more systems have /bin/sh than /bin/bash...

  • @TomGrubbe
    @TomGrubbe Před 2 lety

    This uses tput under the hood to write to the terminal. Nice bash library.

  • @ChristopherCompagnon1AndOnly

    I personally use Zenity.

  • @anon_y_mousse
    @anon_y_mousse Před 2 lety +2

    This is a neat toy, but as others have pointed out, dialog exists, and these scripts don't correctly write to the terminal. It monkeys up the buffer by merely scrolling the window with each refresh instead of creating a proper view window the way most ncurses apps do. I also noticed that you have to kill the script to exit all but one of them, possibly another problem.

  • @gonzalooviedo5435
    @gonzalooviedo5435 Před rokem

    Yes, very good. I'm wondering if there is something similar to interact with programs :)

  • @sterling1989
    @sterling1989 Před 2 lety +1

    How do you add the graphics at the top of the terminal session? I have Neofetch run at the top but have never seen the ghosts and Zelda stuff before. Looks like it changes everytime you open terminal. Very cool!

    • @DistroTube
      @DistroTube  Před 2 lety

      Go to my GitLab and look for shell-color-scripts.

  • @JRCSalter
    @JRCSalter Před 2 lety +1

    I'm intrigued, but from what I can see here, it's not really an 'interface', it's more of a way to display the results of a script.

  • @emacsking4310
    @emacsking4310 Před 2 lety +3

    Elisp has a built-in GUI.

    • @yash1152
      @yash1152 Před 2 lety

      > _"Elisp has a built-in GUI."_
      wow, nice to know

  • @C0ttageChees
    @C0ttageChees Před rokem

    Terminal ghosts! 😮

  • @damianmeneses4382
    @damianmeneses4382 Před 2 lety

    amazing ep, i've be learn much things, thank you

  • @mels4413
    @mels4413 Před 2 lety

    Hey DT, I'm interested in hearing your point of view on image codecs (especially AVIF and JPEG XL), and the implications on web development and the average user.

  • @paxdriver
    @paxdriver Před 2 lety

    Great vid thanks! Never heard of this before

  • @alanjrobertson
    @alanjrobertson Před 2 lety

    Interesting vid, thanks. BTW what's your command prompt setup there? Looks quite nice and minimalist...

  • @vicmac3513
    @vicmac3513 Před 2 lety +1

    Would you make tutorial how to compile a kernel? I've tried 2 days now and can't make even Manjaro .config without any changes to boot.

  • @reveninja5252
    @reveninja5252 Před rokem

    I think you might get into ncurses with python instead of c language. But I am only starting to learn that, so you need to check that info.

  • @denisde4ev
    @denisde4ev Před 2 lety

    I will try to use for some of my scripts it, but it seems a bit pointless to use it just to draw borders.
    I need something to interact with the keyboard depending on focused window and maybe interact with mouse for all windows.

  • @Amitkrdas17
    @Amitkrdas17 Před 2 lety

    well I will try this with solaris... :D

  • @ChurchHatesTucker
    @ChurchHatesTucker Před 2 lety +3

    Oh, I have some very complex curses for bash...

  • @IWorkInPixels
    @IWorkInPixels Před 2 lety

    Does anyone know if there's a version of this (or some other solution) for doing this type of thing on the Mac command line with zsh?
    I have tried some of the examples, and they partially work, I have ncurses installed via brew, but some of the features I need, like being able to select choices, do not work.

  • @jose007108
    @jose007108 Před rokem

    awesome vidio man

  • @sammaasc
    @sammaasc Před 2 lety

    Hi there is something I do not understand how do you execute code after your ui is rendered

  • @linuxninja
    @linuxninja Před 2 lety

    whiptail vs dialog - that ever-persistent war

  • @cheetahstrike2137
    @cheetahstrike2137 Před rokem

    Of course it can’t print kernel messages without sudo, I’m guessing that’s the problem with the error there

  • @truko22
    @truko22 Před 5 měsíci

    Que genial 🤩

  • @AndersJackson
    @AndersJackson Před 2 lety +1

    And of course, you can use Emacs as all three modes. CLI, TUI and GUI.

  • @Sra4825
    @Sra4825 Před 2 lety

    Hey DT. Can you make a video on how to integrate polybar with xmonad? I have been able to setup a working config of xmonad thanks to your videos, and have not been able to integrate polybar with xmonad after following your example config. I think it will be a lot of help if you could kindly make a video on the same.

  • @carlfranz6805
    @carlfranz6805 Před rokem

    Nifty.

  • @KyleLanmon
    @KyleLanmon Před 2 lety

    You could do a video about the ShellCheck linter

  • @ggorg0
    @ggorg0 Před 2 lety +1

    that uptime tho

  • @m1kr0kosmos
    @m1kr0kosmos Před 2 lety

    Do you still use User-friendly interactive Unix shell?

  • @firstnamelastname2298
    @firstnamelastname2298 Před 2 lety

    More valuable question - how to turn GUI into cli application? Because you can't write a script to automate your routine actions in GUI app. So.. GUI is pointless in long term.

  • @anandmaurya3389
    @anandmaurya3389 Před 2 lety

    Good vid

  • @reveninja5252
    @reveninja5252 Před rokem

    Does it allow you to make a menu?

  • @draosf
    @draosf Před 2 lety

    Off-topic question: Why "The Linux Foundation" pops up almost everywhere, as a suggestion along with DT videos and Twitter! Even when I click not interested it keeps popping up. I don't have anything against them but I don't think they represent the Linux or FOSS community.

  • @yb1829
    @yb1829 Před 2 lety

    why is obs taking up to 120% ? 5:31

    • @ltxr9973
      @ltxr9973 Před 2 lety +1

      Probably 100% == 1 core

    • @yb1829
      @yb1829 Před 2 lety +1

      @@ltxr9973 thanks

  • @cc15xx1
    @cc15xx1 Před 2 lety

    Hello ;)

  • @overclucker
    @overclucker Před 2 lety

    Almost every language has curses, tk, gtk, and qt bindings, so you aren't stuck with C.

  • @InfinitySiam
    @InfinitySiam Před 2 lety +1

    do you use zsh?

    • @DistroTube
      @DistroTube  Před 2 lety +1

      Fish was the interactive shell in this video. But yes, I have zsh installed too. And bash, of course.

    • @henriquefr4543
      @henriquefr4543 Před 2 lety

      @@DistroTube Why use bash or zsh since fish has many more features like suggestions? I use bash for scripting, but I don't see why I would want to use it as my main shell.

    • @groos3449
      @groos3449 Před 2 lety +7

      @@henriquefr4543 Fish is not POSIX-compliant, using fish is basically like using python as your shell

    • @QmVuamFtaW4
      @QmVuamFtaW4 Před 2 lety

      @@groos3449 true but not true but also kind of true

    • @twb0109
      @twb0109 Před 2 lety +1

      @@groos3449 you can do it with xonsh

  • @distant6606
    @distant6606 Před 2 lety +5

    First :D

    • @DistroTube
      @DistroTube  Před 2 lety +8

      Confirmed! And don't listen to the haters. WE ALL CARE! :D

    • @garygranato9164
      @garygranato9164 Před 2 lety +3

      @@DistroTube ha ha ha h the other guy was just upset that someone else beat him to it :) ps was whip tail not able to do the same job

    • @monkyyy0
      @monkyyy0 Před 2 lety

      2nd

    • @distant6606
      @distant6606 Před 2 lety

      @@DistroTube thnx :D

  • @topherfungus8424
    @topherfungus8424 Před 2 lety +1

    The thing is that ncurses is pretty portable, but this library isn't. It doesn't seem like it would be a good solution except for personal scripts on your home environment

    • @tylerdean980
      @tylerdean980 Před 2 lety +1

      It’s just bash, so if you’re using it like a library not portable, but you can just paste the functions into your script and then it’s ultra portable

  • @theodorealenas3171
    @theodorealenas3171 Před 2 lety

    Wait... Can you have buttons and all?
    It's a bit of a shame if it's just an info display. There are many tools to do that. Even Vim lol. Ok don't do that.

  • @piotrwyrw
    @piotrwyrw Před 2 lety

    Hello

  • @smeggers
    @smeggers Před 2 lety +1

    Segundo (⌐■-■)

  • @AkamiChannel
    @AkamiChannel Před rokem

    You like Zelda?

  • @kingpain2
    @kingpain2 Před 2 lety +3

    Python has a decent ncurses library. You might check it out since you do know python DT (but you probably already knew that. I'd honestly just like to see what you could do with it! Great work!)

    • @brunoais
      @brunoais Před 2 lety +1

      Indeed. One specialized library that uses it is tqdm!

  • @abhilashsrivastava937
    @abhilashsrivastava937 Před 2 lety +1

    Chmod u+x is better.

  • @herrkrake8106
    @herrkrake8106 Před 2 lety +4

    It's very bad idea to use `bash' to process massive scripts like at that repository, because `bash' is the slowest shell in the world ever. As a rule of thumb one should use `dash' to speed up scripts with fallback to `ksh' if some complicated functionality is needed. Yet Google got style guides, which telling that one should avoid scripts larger then 100 LOF. Shell scripting sould be a glue. It's crazy to build everything only with a duct tape and hammer nails with a microscope.

    • @007arek
      @007arek Před 2 lety +2

      It's better to just use a "normal" programming language. ;)

    • @youtube.user.1234
      @youtube.user.1234 Před 2 lety

      @@007arek you mean like python?

    • @herrkrake8106
      @herrkrake8106 Před 2 lety +2

      @@youtube.user.1234 C lang, my friend, C lang. Or Go lang if one is lazy as me.

    • @herrkrake8106
      @herrkrake8106 Před 2 lety

      @@007arek that's what I was talking about.

    • @007arek
      @007arek Před 2 lety +1

      @@youtube.user.1234 With simple scripts I'd go with Lua.

  • @herrkrake8106
    @herrkrake8106 Před 2 lety +1

    Derek, take care of your face skin. Moisture it properly, when going outside use SPF. You need to treat inflammation of melonocytes, undergo IPL therapy. Visit your dermatologist or cosmetic esthetician for more information. There's a lot unhealthy pigmentation on your skin.

  • @rostislavsvoboda7013
    @rostislavsvoboda7013 Před 2 lety

    Bash is one of the worst programming language imitations ever! Please stop this nonsense and for anything longer that 20 lines use some actual programming(!) language like python for example. (Or even better some LISP dialect, e.g. Clojure or Racket.)

  • @lucianochadru4064
    @lucianochadru4064 Před 2 lety

    Why make graphical interface inside graphical emulated terminal ! This i so funny ^^
    You know it's like, using tiling vim inside a tiling terminal inside a tiling window manger! Could just use the window manager, right! haha!
    Try rust / wasm +flutter with webcontainer funnier :) No bloat straight forward apps available everywhere :) This is also a way to make ideas travel around the world!