Transform Your Scripts With Bash Simple Curses

Поділитися
Вставка
  • Опубліковано 30 січ 2025

КОМЕНТАРІ •

  • @PatriceFERLET
    @PatriceFERLET 2 роки тому +305

    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 2 роки тому +9

      Thanks for making it

    • @juancarlosescarti4117
      @juancarlosescarti4117 2 роки тому +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 Рік тому +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 Рік тому +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 UA-cam 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 ;)

    • @beepboop-o5s
      @beepboop-o5s 9 місяців тому

      thanks brother! pull requests incoming lol

  • @Finkelfunk
    @Finkelfunk 2 роки тому +26

    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 2 роки тому

      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 2 роки тому +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 2 роки тому

      @@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 2 роки тому +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 2 роки тому +71

    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 2 роки тому +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 2 роки тому +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 2 роки тому +5

      @@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 2 роки тому

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

    • @cjbarroso
      @cjbarroso 2 роки тому +1

      @@anon_y_mousse and I

  • @vkottler
    @vkottler 2 роки тому

    I really appreciate how you don't get random details about Linux (or computers in general) wrong like a lot of folks on UA-cam 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!

  • @baneblade__
    @baneblade__ 2 роки тому +16

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

  • @bradleyeverson697
    @bradleyeverson697 2 роки тому +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.

  • @IainNitro
    @IainNitro 2 роки тому +44

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

    • @senjougahara9606
      @senjougahara9606 2 роки тому

      what do you mean sir?

    • @IainNitro
      @IainNitro 2 роки тому +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 2 роки тому +5

      computers are boring unless they're used for programming

    • @herrkrake8106
      @herrkrake8106 2 роки тому

      @@TheSulross or for porn!

    • @herrkrake8106
      @herrkrake8106 2 роки тому +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."

  • @AliensInc.
    @AliensInc. 2 роки тому

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

  • @speedyfox9080
    @speedyfox9080 2 роки тому +3

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

  • @christophejournoud2773
    @christophejournoud2773 2 роки тому +15

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

    • @samsungsarsamsungsar7792
      @samsungsarsamsungsar7792 2 роки тому

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

  • @AndersJackson
    @AndersJackson 2 роки тому +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.

  • @stewpidmoney6634
    @stewpidmoney6634 2 роки тому +14

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

  • @AudioKuroneko
    @AudioKuroneko 2 роки тому +2

    Well explained , and informative!

  • @genghiskhan5685
    @genghiskhan5685 2 роки тому

    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.

  • @hellobri4n
    @hellobri4n 2 роки тому +3

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

  • @ltxr9973
    @ltxr9973 2 роки тому

    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.

  • @davidh.4944
    @davidh.4944 2 роки тому +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 <

  • @linuxninja
    @linuxninja 2 роки тому +85

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

    • @youtube.user.1234
      @youtube.user.1234 2 роки тому +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 2 роки тому +2

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

    • @denoww9261
      @denoww9261 2 роки тому +14

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

    • @yash1152
      @yash1152 2 роки тому

      4:04

    • @samgould8567
      @samgould8567 2 роки тому +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.

  • @JollyboatBros
    @JollyboatBros 2 роки тому +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)

  • @troelse.nrmlle4625
    @troelse.nrmlle4625 Місяць тому

    Thank you for this video.

  • @damianmeneses4382
    @damianmeneses4382 2 роки тому

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

  • @paxdriver
    @paxdriver 2 роки тому

    Great vid thanks! Never heard of this before

  • @miriam-english
    @miriam-english 2 роки тому +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 2 роки тому

      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...

  • @Jack-gb2nz
    @Jack-gb2nz 2 роки тому +2

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

  • @sterling1989
    @sterling1989 2 роки тому +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  2 роки тому

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

  • @TomaszB
    @TomaszB 6 місяців тому

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

  • @alanjrobertson
    @alanjrobertson 2 роки тому

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

  • @anon_y_mousse
    @anon_y_mousse 2 роки тому +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.

  • @mels4413
    @mels4413 2 роки тому

    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.

  • @robertcooperAZ
    @robertcooperAZ 6 місяців тому

    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.

  • @IvanGarcerant
    @IvanGarcerant 2 роки тому +4

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

    • @yash1152
      @yash1152 2 роки тому

      can you explain a li'l bit more?

    • @IvanGarcerant
      @IvanGarcerant 2 роки тому +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 2 роки тому +1

      @@IvanGarcerant ohkay. thanks

  • @JRCSalter
    @JRCSalter 2 роки тому +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.

  • @jackt-z2m
    @jackt-z2m 2 роки тому +3

    Elisp has a built-in GUI.

    • @yash1152
      @yash1152 2 роки тому

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

  • @IanHaver
    @IanHaver 2 роки тому +3

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

    • @d.8362
      @d.8362 2 роки тому +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.

  • @vicmac3513
    @vicmac3513 2 роки тому +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.

  • @jose007108
    @jose007108 2 роки тому

    awesome vidio man

  • @TomGrubbe
    @TomGrubbe 2 роки тому

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

  • @denisde4ev
    @denisde4ev 2 роки тому

    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.

  • @ChristopherCompagnon1AndOnly
    @ChristopherCompagnon1AndOnly 2 роки тому +3

    I personally use Zenity.

  • @truko22
    @truko22 9 місяців тому

    Que genial 🤩

  • @gonzalooviedo5435
    @gonzalooviedo5435 Рік тому

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

  • @m1kr0kosmos
    @m1kr0kosmos 2 роки тому

    Do you still use User-friendly interactive Unix shell?

  • @C0ttageChees
    @C0ttageChees 2 роки тому

    Terminal ghosts! 😮

  • @sammaasc
    @sammaasc 2 роки тому

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

  • @IWorkInPixels
    @IWorkInPixels 2 роки тому

    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.

  • @KyleLanmon
    @KyleLanmon 2 роки тому

    You could do a video about the ShellCheck linter

  • @yb1829
    @yb1829 2 роки тому

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

    • @ltxr9973
      @ltxr9973 2 роки тому +1

      Probably 100% == 1 core

    • @yb1829
      @yb1829 2 роки тому +1

      @@ltxr9973 thanks

  • @Sra4825
    @Sra4825 2 роки тому

    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.

  • @linuxninja
    @linuxninja 2 роки тому

    whiptail vs dialog - that ever-persistent war

  • @reveninja5252
    @reveninja5252 2 роки тому

    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.

  • @carlfranz6805
    @carlfranz6805 2 роки тому

    Nifty.

  • @anandmaurya3389
    @anandmaurya3389 2 роки тому

    Good vid

  • @Amitkrdas17
    @Amitkrdas17 2 роки тому

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

  • @firstnamelastname2298
    @firstnamelastname2298 2 роки тому

    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.

  • @cheetahstrike2137
    @cheetahstrike2137 Рік тому

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

  • @reveninja5252
    @reveninja5252 2 роки тому

    Does it allow you to make a menu?

  • @draosf
    @draosf 2 роки тому

    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.

  • @InfinitySiam
    @InfinitySiam 2 роки тому +1

    do you use zsh?

    • @DistroTube
      @DistroTube  2 роки тому +1

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

    • @henriquefr4543
      @henriquefr4543 2 роки тому

      @@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 2 роки тому +7

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

    • @QmVuamFtaW4
      @QmVuamFtaW4 2 роки тому

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

    • @twb0109
      @twb0109 2 роки тому +1

      @@groos3449 you can do it with xonsh

  • @killistan
    @killistan 2 роки тому +1

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

    • @yash1152
      @yash1152 2 роки тому

      can u share the ones you looked up then?

    • @killistan
      @killistan 2 роки тому +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.

  • @ggorg0
    @ggorg0 2 роки тому +1

    that uptime tho

  • @AndersJackson
    @AndersJackson 2 роки тому +1

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

  • @distant6606
    @distant6606 2 роки тому +5

    First :D

    • @DistroTube
      @DistroTube  2 роки тому +8

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

    • @garygranato9164
      @garygranato9164 2 роки тому +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 2 роки тому

      2nd

    • @distant6606
      @distant6606 2 роки тому

      @@DistroTube thnx :D

  • @kingpain2
    @kingpain2 2 роки тому +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 2 роки тому +1

      Indeed. One specialized library that uses it is tqdm!

  • @overclucker
    @overclucker 2 роки тому

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

  • @topherfungus8424
    @topherfungus8424 2 роки тому +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 2 роки тому +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

  • @cc15xx1
    @cc15xx1 2 роки тому

    Hello ;)

  • @theodorealenas3171
    @theodorealenas3171 2 роки тому

    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.

  • @AkamiChannel
    @AkamiChannel 2 роки тому

    You like Zelda?

  • @smeggers
    @smeggers 2 роки тому +1

    Segundo (⌐■-■)

  • @abhilashsrivastava937
    @abhilashsrivastava937 2 роки тому +1

    Chmod u+x is better.

  • @piotrwyrw
    @piotrwyrw 2 роки тому

    Hello

  • @herrkrake8106
    @herrkrake8106 2 роки тому +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 2 роки тому +2

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

    • @youtube.user.1234
      @youtube.user.1234 2 роки тому

      @@007arek you mean like python?

    • @herrkrake8106
      @herrkrake8106 2 роки тому +2

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

    • @herrkrake8106
      @herrkrake8106 2 роки тому

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

    • @007arek
      @007arek 2 роки тому +1

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

  • @herrkrake8106
    @herrkrake8106 2 роки тому +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 2 роки тому

    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 2 роки тому

    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!