Skip to content

Vagrant boxes for command-line centric workflows

Notifications You must be signed in to change notification settings

kriipke/termbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

termbox

termbox is a project that provides Vagrant boxes meant to be used as base boxes for work that requires command-line intensive workflows. The repository contains the scripts, Ansible playbooks, and configuration files needed to generate the Vagrant boxes using Hashicorp’s Packer. All termbox VMs are provisioned with a handful of highly useful command line utilities to provide a powerful, user-friendly command-line experience out-of-the-box.

termbox images were designed for those who want to boot up a fresh VM for the purpose of building a temporary lab environment or testing out a new piece of software and would like to have some familiar command line tools installed withoutdoing any manual provisioning. They work equally well as base boxes for building more complex VMs.

The tools that are included in termbox aide in tasks such as:

  • searching for and editing files

  • navigating the filesystem

  • file management

  • system monitoring

  • browsing & interacting with local git repositories

  • searching and navigating logs

In addition to being a solid base box for creating a virtual lab environment, termbox is also a great playground for those who are new to the command-line and want to familiarize themselves with some of the more powerful tools available to them. For these users, I hope that these VMs will make their journey less cumbersome.

For those that wish to extend the functionality of termbox, the Ansible playbooks used to provision the boxes are located at _common/ansible-playbooks.

Generating the boxes

All termbox images are generated from using a minimal install ISO, and thus contain really just the necessary software to run the system and the tools mentioned below before installing the softwares listed below.

To generate a Fedora 32 Vagrant box using Virtualbox as the provider, for example, just run:

cd fedora
packer build -only=virtualbox-iso -vars-file=32.vars fedora.json

The -vars-file argument will contain the packer variables for the major release of the distribution chosen to build, and the final argument will be the json file corresponding to the distribution.

Possible providers include:

  • virtualbox-iso

  • vmware-iso

  • parallels-iso

Possible distributions include:

  • Ubuntu

  • Fedora

  • CentOS

Command-line Utilities

Upon booting up a termbox VM, the following commands will be immediately available:

command description type

fd

an intuive, powerful alternative to the find command

binary

rg

an extremely fast way to recursively search files using regular expressions

binary

bat

a clone of cat that supports syntax highlighting

binary

fzf

a powerful fuzzy finder useful for both finding files as well as useful when integrated with vim

binary

lsd

an colorful, featureful alternative to the ls command

binary

tagger

a tool for using extended file attributes to tag and organize files and directories

shell script

shellcheck

a shell script static analysis tool that gives warnings and suggestions for bash/sh shell scripts

binary

bandwhich

a TUI network monitor including bandwidth stats and active connections

binary

kmon

a TUI kernel module monitor

binary

nnn

a lightweight but powerful TUI file manager

package

tig

a powerful TUI interface for git, particularly useful for browsing the history of repositories on the local machine

package

httpie

a user-friendly command-line HTTP client for the API era

package

jq

a lightweight and flexible command-line JSON processor

package

ncdu

a disk usage analyzer with an ncurses interface

package

upload

upload files from the local machine to file-sharing sites and displays a QR code containing a link to the file for easily open/share the link on a mobile device

shell function

trspaces

replaces all spaces with underscores in files in the working directory

shell function

explain

takes a command and a switch for that command as arguments, e.g. explain tar -x, and prints out the relevant section of the man page explaining what that switch does

shell function

binaries

The pre-compiled binaries are provisioned via another tool I created named provii. These binaries are all installed in /usr/local/bin. If man pages are available for the program in question, they are installed in /usr/local/share/man/. Finally, if shell completions are available they are installed in /usr/local/lib/omz/completion.

packages

All packages are installed using the systems native package manager and should be managed thus.

shell scripts

All shell scripts are installed in /usr/local/bin.

shell functions

All shell functions are installed in /etc/zsh.

Zsh

The default shell for termbox is zsh, a robust and powerful shell that offers many extensions beyond the standard bash shell. Both zsh and oh-my-zsh, a large set of zsh plugins, are installed system-wide.

To modify the zsh init files, i.e. add a custom script or alias, simply add it to a file with the .zsh extension to the /etc/zsh directory or modify the system zshrc located at /etc/zshrc.

Neovim

In addition to the command line utitlies above termbox also comes pre-installed with nvim and a handful of useful plugins. Additionally, the nvim initialization files include some handy keybindings.

plugins

ale / lightline-ale

check syntax in vim/neovim asynchronously and fix files

vim-commentary

intelligently comment/uncomment lines based on filetype

vim-surround

surround or strip quotes, parenthesis, etc. to/from areas of text

vim-fugitive

an amazing git wrapper for vim/neovim

fzf.vim

fuzzy search (in buffer, across buffers, in current directory, etc.)

vim-polyglot

a pleathora of useful syntax files for various file formats

lightline.vim

enhanced, lightweight vim/neovim status bar

nerdtree / nerdtree-git-plugin

browse files in project directory while displaying git status for each file

nnn.vim

open nnn in a popup window, useful for moving/rename files

tagbar / vim-gutentags

display tags generated by gutentags in a sidebar for nagivation

vimux

pipe output of commands run in vim/neovim into a new tmux pane

keybindings

The leader key has been changed to ; for convenience. Below are some of the most useful keybindings available (see /etc/vimrc.local for all available bindings):

let mapleader = ";"

change window

" Move the cursor to the window...

" ;k - above current one
nmap <leader>k <C-w>k

" ;j - below current one
nmap <leader>j <C-w>j

" ;h - to the left of the current one
nmap <leader>h <C-w>h

" ;l - to the right of the current one
nmap <leader>l <C-w>l

" ;<space> - previously selected
nmap <leader><space> <C-w>p

split window

" Split current window, creating a new view of the current buffer...

" C-j - below the current one
nmap <C-j> :belowright split<cr>

" C-k - above the current one
nmap <C-k> :split<cr>

" C-h - to the left of the current one
nmap <C-h> :vsplit<cr>

" C-l - to the right of the current one
nmap <C-l> :belowright vsplit<cr>

new window

" Interactively populate a new window with an open buffer...

" ;J - below the current window
nmap <leader>J :belowright new +Buffers<cr>

" ;K - above the current window
nmap <leader>K :new +Buffers<cr>

" ;H - to the left the current window
nmap <leader>H :vnew +Buffers<cr>

" ;L - to the right of the current window
nmap <leader>L :belowright vnew +Buffers<cr>

resize window

" CTRL + arow keys

nmap <C-down> <C-w>-
nmap <C-up>	<C-w>+
nmap <C-left> <C-w><
nmap <C-right> <C-w>>

previous/next syntax error

" C-e - jump to next syntax error
nmap <silent> <C-e> <Plug>(ale_next_wrap)

" C-E - jump to previous syntax error
nmap <silent> <C-E> <Plug>(ale_previous_wrap)

file browsing/management

" ;n - toggle nnn file manager
nmap <leader>n :NnnPicker<cr>

" ;e - toggle NERDTree file browser
nmap <leader>e :NERDTree<cr>

tagbar

" ;t - open/close tagbar
nmap <leader>tt :TagbarToggle<cr>

" ;tt - temporarily open tagbar to jump to a particular tag
nmap <leader>t :TagbarOpenAutoClose<cr>

fuzzy searching

" C-/ - fuzzy find lines in all open buffers
nmap C-/ :Lines<cr>

" ;/ - fuzzy find lines in current buffer
nmap <leader>/ :BLines<cr>

" ;f - fuzzy find files in current working directory
nmap <leader>f :Files<cr>

" ;b - fuzzy find open buffers
nmap <leader>b :Buffers<cr>

miscellaneous

" ;c - comment/uncomment selected lines lines
vmap <leader>c :Commentary<cr>

" ;d - show changes made since file was last saved
nmap <leader>d :DiffOrig<cr>

git

" ;gs - show status of current Git repository in a new tab
nmap <leader>gs :tab :Gstatus<cr>

" ;gl - show Git log in a new tab
nmap <leader>gl :tab :Gclog<cr>