All Projects → sgtpep → Pmenu

sgtpep / Pmenu

Licence: gpl-3.0
A dynamic terminal-based menu inspired by dmenu written in Python without dependencies with an optional MRU ordering which could also be used as an application launcher and CtrlP alternative.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pmenu

Notcurses
blingful character graphics/TUI library. definitely not curses.
Stars: ✭ 542 (+482.8%)
Mutual labels:  ncurses
Silver Sniffle
Ncurses TCP Chat
Stars: ✭ 38 (-59.14%)
Mutual labels:  ncurses
Pacmixer
an alsamixer alike for PulseAudio.
Stars: ✭ 78 (-16.13%)
Mutual labels:  ncurses
Sngrep
Ncurses SIP Messages flow viewer
Stars: ✭ 605 (+550.54%)
Mutual labels:  ncurses
Rogue Craft Sp
Rogue Craft is an ncurses based roguelike/sandbox/RPG game
Stars: ✭ 12 (-87.1%)
Mutual labels:  ncurses
Snoo
A Reddit command line client written in Node.js, using modern ES-features
Stars: ✭ 39 (-58.06%)
Mutual labels:  ncurses
Cfiles
A ncurses file manager written in C with vim like keybindings
Stars: ✭ 319 (+243.01%)
Mutual labels:  ncurses
Pulseaudio Mixer Cli
Interactive python/ncurses UI to control volume of pulse streams
Stars: ✭ 86 (-7.53%)
Mutual labels:  ncurses
Profanity
Ncurses based XMPP client
Stars: ✭ 966 (+938.71%)
Mutual labels:  ncurses
Corewar
School 42 project // Implementation of programming game “Core War” [Champions + Assembler + Disassembler + Virtual Machine + Visualizer]
Stars: ✭ 76 (-18.28%)
Mutual labels:  ncurses
Tvision
A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
Stars: ✭ 612 (+558.06%)
Mutual labels:  ncurses
Trek
Trek is a CLI/ncurses explorer for HashiCorp Nomad clusters.
Stars: ✭ 26 (-72.04%)
Mutual labels:  ncurses
Flow
A realtime log analyzer
Stars: ✭ 69 (-25.81%)
Mutual labels:  ncurses
Pdcurses
PDCurses - a curses library for environments that don't fit the termcap/terminfo model.
Stars: ✭ 604 (+549.46%)
Mutual labels:  ncurses
Ncursesfm
Ncurses File Manager for linux
Stars: ✭ 79 (-15.05%)
Mutual labels:  ncurses
Wavemon
wavemon is an ncurses-based monitoring application for wireless network devices on Linux.
Stars: ✭ 496 (+433.33%)
Mutual labels:  ncurses
Toxic
An ncurses-based Tox client (please make pull requests on the development fork: https://github.com/toktok/toxic)
Stars: ✭ 987 (+961.29%)
Mutual labels:  ncurses
Netbsd Curses
libcurses and dependencies taken from netbsd and brought into a portable shape (at least to musl or glibc)
Stars: ✭ 93 (+0%)
Mutual labels:  ncurses
Turbo
An experimental text editor based on Scintilla and Turbo Vision.
Stars: ✭ 78 (-16.13%)
Mutual labels:  ncurses
Rubiks cube
rubik's cube that runs in your terminal!
Stars: ✭ 73 (-21.51%)
Mutual labels:  ncurses

pmenu

A dynamic terminal-based menu inspired by dmenu written in Python without dependencies with an optional MRU ordering which could also be used as an application launcher and CtrlP alternative.

Discussion: https://bbs.archlinux.org/viewtopic.php?id=201674.

Dependencies

Python 3.3+.

Usage examples

Display some menu items:

echo -e "foo\nbar\nbaz" | pmenu
pmenu foo bar baz
echo -e "foo\nbar" | pmenu baz qux

screencast 1

Pick some file from the current directory:

command ls /usr/bin/ | pmenu
find -maxdepth 3 -type f ! -path "./.git/*" ! -path "./.svn/*" -printf '%P\n' | LC_COLLATE=C sort | pmenu

screencast 2

Pick some file from the current directory for editing in VIM using Ctrl-P shortcut (a la the CtrlP plugin):

function! Pmenu()
  let item_command = "find -maxdepth 3 -type f -regextype posix-egrep ! -regex '.*/(__pycache__|\.git|\.svn|node_modules)/.*' -printf '%P\\n'"
  if isdirectory("./.git")
    let item_command = "git ls-files"
  endif
  let cache_name = fnamemodify(getcwd(), ":t")
  let items = sort(systemlist(item_command))
  let current_item = expand("%:.")
  if !empty(current_item)
    let items = filter(copy(items), "v:val != " . shellescape(current_item))
  endif
  let selected_items = systemlist("pmenu -n " . shellescape(cache_name), items)
  if !empty(selected_items)
    execute "edit " . fnameescape(selected_items[0])
  endif
  redraw!
endfunction
nnoremap <silent> <C-P> :call Pmenu()<CR>
vnoremap <silent> <C-P> :call Pmenu()<CR>

screencast 3

Pick a title from the markdown file and jump to it:

function! PmenuMarkdownTitle()
  let titles = filter(getline(1, '$'), "v:val =~ '^#\\+\\s'")
  let selected_paths = systemlist('pmenu', titles)
  if !empty(selected_paths)
    call search('^#\+\s' . selected_paths[0])
  endif
  redraw!
endfunction
nnoremap <silent> <C-T> :call PmenuMarkdownTitle()<CR>

Pick and show a definition from the WordNet dictionary on the dict server (dict.org by default) using either the curl or dict command:

pmenu -c "m={} && curl -s \"dict://dict.org/m:\${m:-a}:wn:prefix\" | awk -F \\\" '! array[tolower(\$2)]++ { print \$2 }'" | xargs -I '{}' curl -s "dict://dict.org/d:{}:wn" | grep -vP "^(\d+ |\.)" | less
pmenu -c "dict -fm -d wn -s prefix -- {} | awk '! array[tolower(\$4)]++ { print \$4 }'" | xargs dict -d wn | less

Pick and start a VirtualBox virtual machine:

vboxmanage startvm "`vboxmanage list vms | sed 's/^"\(.*\)".*/\1/' | pmenu`"

Pick and jump to a subdirectory in ~/Projects:

cd "`cd ~/Projects; pmenu *`"

pmenu-run

The script pmenu-run is an example of an application launcher built with pmenu similar to dmenu_run, gmrun and bashrun. It builds the menu from system *.desktop files and launches the selected item in the current terminal or detached from it depending on the application type.

Bind any shortcut using your desktop preferences to one the following commands depending of what terminal emulator you use:

xterm -e pmenu-run
urxvt -e pmenu-run

pmenu-run passes all provided additional options to pmenu. This could be used to add more items to the launcher menu, like pmenu-run command1 command2 command3.

Installation

Copy pmenu (and optionally pmenu-run) to any location from your $PATH, say /usr/local/bin.

There is the AUR package for Arch Linux: https://aur.archlinux.org/packages/pmenu/.

Command-line interface

usage: pipe newline-separated menu items to stdin and/or pass them as positional arguments

positional arguments:
  item                  the menu item text

optional arguments:
  -h, --help            show this help message and exit
  -c COMMAND, --command COMMAND
                        the shell command which output will populate the menu
                        items on every keystroke ({} will be replaced by the
                        current input text)
  -n NAME, --name NAME  the cache file name with the most recently used items
  -p PROMPT, --prompt PROMPT
                        the prompt text
  -v, --version         show program's version number and exit

Keyboard shortcuts

  • Ctrl-C, Ctrl-G, Ctrl-[, Escape: quit without selecting an item
  • Ctrl-H, Backspace: delete the character before the cursor
  • Ctrl-I, Tab: complete the selected item
  • Ctrl-J, Ctrl-M, Enter: quit and output the selected item
  • Ctrl-N, 'Down': select the next item
  • Ctrl-P, 'Up': select the previous item
  • Ctrl-U: delete the entire line
  • Ctrl-W: delete the word before the cursor

Alternatives

dmenu-like menus

dmenu wrappers

Application launchers

Vim menus

License and copyright

The project is released under the General Public License (GPL), version 3.

Copyright © 2015, Danil Semelenov.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].