TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Bashsimplecurses: Simple curses library made in bash to draw terminal interfaces

85 点作者 tambourine_man10 个月前

9 条评论

iam-TJ10 个月前
There&#x27;s some quite impressive and interesting bash (and other shell) exploration in the matrix.org &quot;Fun Shell Scripting&quot; room from time to time; usually when someone asks an obscure question and a few people dive down a rabbit-hole.<p>One oft overlooked feature is bash supports dynamically loadable &#x27;builtins&#x27; as shared object modules so it wouldn&#x27;t take much to create a &#x27;proper&#x27; wrapper around libncurses.<p>Debian and derivatives have the package &quot;bash-builtins&quot; that has a lot of examples including wrapping&#x2F;implementing many coreutils tools.
评论 #41088991 未加载
评论 #41092771 未加载
atomicnumber310 个月前
This is cool, I&#x27;ve used curses UIs to build various small things that need to be a) vaguely easy to use (so, complicated CLIs are out. oncalls need to be able to use this at 3am while half their brain is still sleeping) and b) accessible over ssh because we have secure ssh access to these envs but ~nothing else.<p>So I love TUIs.<p>That said, I&#x27;m always a little puzzled about why people build these libraries in bash. Is it simply curiosity? Maybe, and if so, godspeed.<p>But if it&#x27;s driven by pragmatism, let me assure the reader that if there are limits to the extents I will go to get python somewhere instead of writing even a somewhat nontrivial bash script, I have yet to find them. Not only is bash just kind of really annoying to program in, it&#x27;s also nearly unethical to program in. Let me link the 2 I always link to when someone tells me they&#x27;re &quot;working on&quot; a bash script.<p>Steam deleted my entire system (empty variable expansion): <a href="https:&#x2F;&#x2F;github.com&#x2F;valvesoftware&#x2F;steam-for-linux&#x2F;issues&#x2F;3671">https:&#x2F;&#x2F;github.com&#x2F;valvesoftware&#x2F;steam-for-linux&#x2F;issues&#x2F;3671</a><p>Bumblebee deletes &#x2F;usr due to space: <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;softwaregore&#x2F;comments&#x2F;2hsdo6&#x2F;giant_bug_causing_usr_to_be_deleted_so_sorry&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;softwaregore&#x2F;comments&#x2F;2hsdo6&#x2F;giant_...</a><p>So I warn people: if you use python, you&#x27;ll categorically avoid being the third entry in my list.
评论 #41087536 未加载
评论 #41087324 未加载
评论 #41087444 未加载
JNRowe10 个月前
Zsh users get a bundled curses module; see zsh&#x2F;curses¹ in zshmodules(1). It is a <i>very</i> thin wrapper, so it works how you&#x27;d expect from other uses. There is a tetris implementation using zsh&#x2F;curses that ships with zsh², and you can use it as a nice comparison to the non-curses implementation that also comes with zsh³.<p>I&#x27;ve used zsh&#x2F;curses a few times to hack together little interfaces, and it is quite workable. It makes things far simpler once you start reaching for terminfo&#x27;s capabilities that require you to think about state too much. A friend of mine wrote a little mblaze⁴ frontend using it, and it felt like using single mailbox mutt with less than a hundred lines of code.<p>I was expecting the linked project to be a loadable module too given that bash also supports them, but it is actually a little more interesting to look at given it implements a bunch of the behaviour itself on top of tput calls.<p>¹ <a href="https:&#x2F;&#x2F;zsh.sourceforge.io&#x2F;Doc&#x2F;Release&#x2F;Zsh-Modules.html#The-zsh_002fcurses-Module" rel="nofollow">https:&#x2F;&#x2F;zsh.sourceforge.io&#x2F;Doc&#x2F;Release&#x2F;Zsh-Modules.html#The-...</a><p>² <a href="https:&#x2F;&#x2F;github.com&#x2F;zsh-users&#x2F;zsh&#x2F;blob&#x2F;master&#x2F;Functions&#x2F;Misc&#x2F;tetriscurses">https:&#x2F;&#x2F;github.com&#x2F;zsh-users&#x2F;zsh&#x2F;blob&#x2F;master&#x2F;Functions&#x2F;Misc&#x2F;...</a><p>³ <a href="https:&#x2F;&#x2F;github.com&#x2F;zsh-users&#x2F;zsh&#x2F;blob&#x2F;master&#x2F;Functions&#x2F;Misc&#x2F;tetris">https:&#x2F;&#x2F;github.com&#x2F;zsh-users&#x2F;zsh&#x2F;blob&#x2F;master&#x2F;Functions&#x2F;Misc&#x2F;...</a><p>⁴ <a href="https:&#x2F;&#x2F;git.vuxu.org&#x2F;mblaze&#x2F;about&#x2F;" rel="nofollow">https:&#x2F;&#x2F;git.vuxu.org&#x2F;mblaze&#x2F;about&#x2F;</a>
ofalkaed10 个月前
I have a fondness for bash abuse and those odd sort of people who get fixated on bash. bed [0] the bash editor is one of my favorite examples, always surprised by how short and concise it is, far from a great editor but a great exercise and I learned a thing or two about the bash way from it.<p>0. <a href="https:&#x2F;&#x2F;github.com&#x2F;comfies&#x2F;bed">https:&#x2F;&#x2F;github.com&#x2F;comfies&#x2F;bed</a>
hyperupcall10 个月前
I&#x27;ve made a similar library called bash-term[1], which is similar, but only has functions for lower-level operations, like moving the cursor to the end of the line, etc. It&#x27;s also cleaner and has almost no global variables.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;bash-bastion&#x2F;bash-term">https:&#x2F;&#x2F;github.com&#x2F;bash-bastion&#x2F;bash-term</a>
layer810 个月前
If you only need simple dialogs, <i>whiptail</i> is usually installed on Debian-based systems: <a href="https:&#x2F;&#x2F;en.wikibooks.org&#x2F;wiki&#x2F;Bash_Shell_Scripting&#x2F;Whiptail" rel="nofollow">https:&#x2F;&#x2F;en.wikibooks.org&#x2F;wiki&#x2F;Bash_Shell_Scripting&#x2F;Whiptail</a>
woodsie10 个月前
Bash with a #!&#x2F;bin&#x2F;bash shebang. Typical GNU cultural imperialism. &quot;Everyone has a Bash and it&#x27;s always kept in &#x2F;bin.&quot;
评论 #41088549 未加载
jackhab10 个月前
If the only purpose of this project is to create windows in Bash one might easily replace it with tmux panes.
rsync10 个月前
This reminds me of something I have always wanted in the UNIX ecosystem:<p>&quot;topify&quot;<p>... which is the word I would use to describe a primitive that will take line inputs from stdio and display them in a &#x27;top&#x27; style output, presumably with curses.<p>Maybe there is more complication here than I have thought out but ... if I can output a standard line with columns I have already defined (perhaps in an &#x27;awk&#x27; pipeline or whatever) then I would like a way to refresh them, in some order.<p>I am fairly certain this does not exist ...
评论 #41088516 未加载
评论 #41091818 未加载