ch

所属分类:GPT/ChatGPT
开发工具:Shell
文件大小:0KB
下载次数:0
上传日期:2024-03-25 21:12:46
上 传 者sh-1993
说明:  从终端访问ChatGPT,不再切换到浏览器选项卡
(Access ChatGPT from your terminal, no more context switching to browser tabs)

文件列表:
tests/
LICENSE
Makefile
ch

ChatGPT Shell Script --- Take your productivity to the next level with `ch`, the POSIX-compliant shell script/library: - Access ChatGPT from your terminal, no more context switching to browser tabs. - Save money: the typical monthly cost of ChatGPT API is much lower than the fixed fee for web access. - Program ChatGPT with standard shell tools like pipes, redirects and grep. No more copy and paste! ### System Requirements - An operating system with a POSIX-compatible shell. Tested on: Linux, MacOS, BSD, Android (via Termux). - A valid OpenAI ChatGPT API key. Create one at OpenAI. - The curl and jq utilities to be installed. - An Internet connection. ### Usage ch [Option] Options a|again in case of error, send current chat again c|current switch the current chat to a differerent title g|gen generate title for current chat h|help print this help p|print print out the current chat l|list list all chat titles n|new <prompt> start a new chat r|reply <reply> reply to the current chat t|title print the current chat title Arguments in <angle brackets> are read from STDIN if not present. ### Example $ ./ch n is it possible to '"delete"' lines of output in a terminal, or simulate it using ANSI escape sequences? Yes, it is possible to "delete" lines of output in a terminal or simulate it using ANSI escape sequences. Here's an example of how you can simulate deleting lines in a terminal using ANSI escape sequences in Python: ... I also recorded a [video](https://www.youtube.com/watch?v=9aYUvLeM0yo) with more background on the rationale for `ch` and example uses. ### Library You can also "source" `ch` in your own shell scripts to use it as an API library. See `tests/run.sh` for an example. ### MIT License Copyright (c) 2023 David Farrell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Depends on usage, in my case I went from spending $20 to less than $2 per month. </div> <hr> <div><B>近期下载者</B>:</div> <div id="download-users"></div> <hr> <div><B>相关文件</B>:</div> <div id="relate-items"></div> <hr> <div><B>评论</B>:[<a href=/Download/comment/id/1711518979121804.html data-toggle=modal data-target="#myModal">我要评论</a>] [<a class='pop-a' href=/Download/report/id/1711518979121804.html>举报此文件</a>]</div> <div id="file-comments"></div> <hr> <div><B>收藏者</B>:</div> <div id="favor-users"></div> <p></p> </div> <div class="col-xs-12 col-md-4"> <div class="ad-sidebar text-center"> <div class="ad-300"> </div> </div> </div> </div> </div> </div> <div class="my-footer"> <div class="container"> <div class="pull-right"> </div> <div> <a href="http://www.pudn.com" target=_blank>© 联合开发网 from 2004</a> | <a href="/Index/contact.html">联系站长</a> | <a href=" https://beian.miit.gov.cn" target=_blank>湘ICP备2023001425号</a> | <a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=43010502000604" target=_blank>网安备43010502000604</a> | </div> </div> </div> </div><!-- /wrapper--> <!-- page specific plugin scripts --> <!-- inline scripts related to this page --> <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> </div> </div> </div><!-- /.modal-table --> </body> <script type="text/javascript"> $(document).on('click', '.list-more', function(){ var id=$(this).attr('data-id'); $('#list-'+id).css('max-height',$('#list-'+id)[0].scrollHeight); $(this).removeClass('list-more'); $(this).addClass('list-hide'); $(this).html('<i class="fa fa-angle-double-up"></i>'); //$(this).hide(); return false; }); $(document).on('click', '.list-hide', function(){ var id=$(this).attr('data-id'); $('#list-'+id).css('max-height','100px'); $(this).removeClass('list-hide'); $(this).addClass('list-more'); $(this).html('<i class="fa fa-angle-double-down"></i>'); return false; }); $("#myModal").on("hidden.bs.modal", function() { $(this).removeData(); }); $(document).on("click",".keyword",function(){ var keyword=$(this).attr("keyword"); var type_id=$(this).attr("type_id"); if(typeof(type_id) =="undefined" || type_id =="") type_id="0"; location.href="http://search.pudn.com/Download/index?keyword="+keyword; return false; }); </script> <script type="text/javascript" src="/js/time.js"></script> <script type="text/javascript" src="/js/marked.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('.hide-list').each(function(){ if ($(this)[0].offsetHeight < $(this)[0].scrollHeight){ var id=$(this).attr('id'); id =id.substring(5); $(this).after('<div style="text-align:center"><a href="" class="list-more" data-id="' + id + '"><i class="fa fa-angle-double-down"></i></a></div>'); } }); }); var g_id="1711518979121804"; var keywords =new Array(); keywords[0] ='posix-shell';keywords[1] ='chatgpt';keywords[2] ='OPENAI';keywords[3] ='perplexity'; function get_download_user(){ var url ="/Download/get_download_user/id/"+g_id+".html"; $.get(url,function(ret){ if(ret.length ==0) return; var html=''; for(i in ret){ html =html + '<a href=/User/profile/id/'+ret[i].user_new_id+'.html>'+ret[i].name+'</a> '; } $('#download-users').append(html); }); } function get_relate_item(){ var url ="/Download/get_relate_item/id/"+g_id+'.html'; $.get(url,function(ret){ if(ret.length ==0) return; var html=''; var intro; for(i in ret){ intro =ret[i].intro; for(j in keywords){ var reg =new RegExp(keywords[j],'gmi'); intro =intro.replace(reg,'<font color=brown>'+keywords[j]+'</font>'); } html =html + '[<a href=/Download/item/id/'+ret[i].new_id+'.html>'+ret[i].name+'</a>]  '+intro+'<BR>'; } $('#relate-items').append(html); }); } function get_score_name(score){ switch(score){ case '100': return '很好,推荐下载'; case '85': return '还不错'; case '75': return '一般,勉强可用'; case '50': return '差'; case '3': return '纯粹是垃圾'; case '40': return '和说明完全不符'; case '20': return '文件不全'; case '10': return '不是源代码或资料'; case '5': return '文件有密码,不知道密码'; case '0': return '不能解压或下载失败'; } return ''; } function get_comment(){ var url ="/Download/get_comments/id/"+g_id+'.html'; $.get(url,function(ret){ if(ret.length ==0) return; var total_count =ret.total_count; var data =ret.data; var html=''; for(i in data){ html =html + '<a href="/User/profile/id/'+data[i].user_new_id+'.html" class="uploader">'+data[i].user_name+'</a>: <span class="comment-score">'+get_score_name(data[i].score)+'</span>, '+data[i].content+'<BR>'; } $('#file-comments').append(html); }); } function get_favor(){ var url ="/Download/get_item_favors/id/"+g_id+".html"; $.get(url,function(ret){ if(ret.length ==0) return; var html=''; for(i in ret){ html =html + '<a href=/User/profile/id/'+ret[i].user_new_id+'.html class=user>'+ret[i].name+'</a> '; } $('#favor-users').html(html); }); } // 得到下载这个的用户又下载了什么 function get_more_download(){ } // 得到下载这个的用户又搜索了什么 function get_more_keyword(){ } // 得到论坛相关问题 function get_bbs(){ } // 得到软件工场相关内容 function get_works(){ } // 得到相关聊天室 function get_chat(){ } // 得到相关软件商城信息 function get_shop(){ } // 得到job // 得到学习内容 // 数据 get_download_user(); //get_relate_item(); get_comment(); get_favor(); $('.vote-up').click(function(){ var url="/Download/vote/t/up/id/"+g_id; $.get(url,function(ret){ if(ret.status==0){ alert(ret.info); if(ret.url.length >0) location.href=ret.url; } else{ var s =$('#vote-up-count').html(); if(s =='') s="0"; var count =parseInt(s)+1; $('#vote-up-count').html(count); } }) return false; }); $('.vote-down').click(function(){ var url="/Download/vote/t/down/id/"+g_id; $.get(url,function(ret){ if(ret.status==0) alert(ret.info); else{ var s =$('#vote-down-count').html(); if(s =='') s="0"; var count =parseInt(s)+1; $('#vote-down-count').html(count); } }) return false; }); $('.favor-item').click(function(){ var url="/Favor/add/t/0/id/"+g_id; $.get(url,function(ret){ if(ret.status==0){ alert(ret.info); } else{ var s =$('#favor-count').html(); if(s =='') s="0"; var count =parseInt(s)+1; $('#favor-count').html(count); } }) return false; }); $('.pop-a').click(function(){ var url=$(this).attr('href'); $.get(url,function(ret){ alert(ret.info); //location.reload(); }) return false; }); document.getElementById('readme').innerHTML =marked.parse(document.getElementById('readme').innerHTML); </script> </html>