简单CUI(TUI)启动程序菜单
jj-menu的Python项目详细描述
简单的CUI(TUI)菜单
安装
$ pip install jj-menu
(或$pip install git+https://github.com/ytyng/jj-menu.git)
设置
在任何目录中创建jjfile.py。
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals menu = [ ('list python processes', 'ps -eafw|grep python'), ('move tmp', 'cd /tmp/'), ('list dirs', ['ls .', 'ls ..', 'ls ../..']), ('Git logs (simple)', 'git log --graph --date-order -C -M --pretty=format:"<%h> %ad [%an] %Cgreen%d%Creset %s" ' '--all --date=short'), ('Git logs (verbose)', 'git log --graph --date=iso --decorate --name-status'), ('Copy datetime to pasteboard', 'date +"%Y-%m-%d %H:%M:%S"|pbcopy') ]
和register shell函数(可选)
function jj(){ RESULT_FILE=/tmp/_jj_result jj-menu --result-file=${RESULT_FILE} if [ $? == 0 ]; then history -s `cat ${RESULT_FILE}` source ${RESULT_FILE} fi }
运行
$ jj
或
$ jj-menu
(在未注册的jj shell函数中。在子流程中运行选定的命令。)
键绑定
ESC: Exit Q: Exit k: Up j: Down