Home

Awesome

twf - Tree View Find

twf is a standalone tree view explorer inspired by fzf.

<img src="screenshot.png" width=640>

Features

Installation

Using Homebrew

brew install --HEAD wvanlint/twf/twf

Using Go

Install Go, and ensure that $GOPATH/bin is added to the $PATH.

export GOPATH="$HOME/go"
export PATH="$PATH:$HOME/bin:$GOPATH/bin"

Install the Go binary.

go get -u github.com/wvanlint/twf/cmd/twf

Integrations

In .zshrc

twf-widget() {
  local selected=$(twf --height=0.5)
  BUFFER="$BUFFER$selected"
  zle reset-prompt
  zle end-of-line
  return $ret
}
zle -N twf-widget
bindkey '^T' twf-widget

In .vimrc

function! Twf()
  let temp = tempname()
  execute 'silent ! twf ' . @% . ' > ' . temp
  redraw!
  try
    let out = filereadable(temp) ? readfile(temp) : []
  finally
    silent! call delete(temp)
  endtry
  if !empty(out)
    execute 'edit! ' . out[0]
  endif
endfunction

nnoremap <silent> <Space>t :call Twf()<CR>

In .config/nvim/init.vim

function! TwfExit(path)
  function! TwfExitClosure(job_id, data, event) closure
    bd!
    try
      let out = filereadable(a:path) ? readfile(a:path) : []
    finally
      silent! call delete(a:path)
    endtry
    if !empty(out)
      execute 'edit! ' . out[0]
    endif
  endfunction
  return funcref('TwfExitClosure')
endfunction

function! Twf()
  let temp = tempname()
  call termopen('twf ' . @% . ' > ' . temp, { 'on_exit': TwfExit(temp) })
  startinsert
endfunction

nnoremap <silent> <Space>t :call Twf()<CR>

Usage

twf [flags...] [path]

The binary twf will output the path that you select in the tree view, so it is usable in scripts and from other programs. For example, you can try the following commands:

cat $(twf)
cat $(twf --height=0.5)
vim $(twf)

It is also possible to locate and highlight a file given as an argument.

twf path/to/subdir/file

Default keybindings

Flags