GithubHelp home page GithubHelp logo

tmux-plugins / tmux-sidebar Goto Github PK

View Code? Open in Web Editor NEW
525.0 8.0 30.0 92 KB

A sidebar with the directory tree for the current path. Tries to make tmux more IDE like.

License: MIT License

Shell 100.00%

tmux-sidebar's Introduction

Tmux Sidebar

tmux-sidebar does one thing: it opens a tree directory listing for the current path. It's fast, convenient and works great with vim.

screenshot

Some of the features that make the plugin more appealing than doing the same thing manually each time:

  • fast
    Much faster than doing each step manually.
  • smart sizing
    Sidebar remembers its size, so the next time you open it, it will have the exact same width. This is a per-directory property, so you can have just the right size for multiple dirs.
  • toggling
    The same key binding opens and closes the sidebar.
  • uninterrupted workflow
    The main prefix + Tab key binding opens a sidebar but does not move cursor to it.
  • pane layout stays the same
    No matter which pane layout you prefer, sidebar tries hard not to mess your pane splits. Open, then close the sidebar and everything should look the same.

Requirements: tmux 1.9 or higher, tree recommended but not required

Tested and working on Linux, OSX and Cygwin.

Key bindings

  • prefix + Tab - toggle sidebar with a directory tree
  • prefix + Backspace - toggle sidebar and move cursor to it (focus it)

Installation with Tmux Plugin Manager (recommended)

Add plugin to the list of TPM plugins in .tmux.conf:

set -g @plugin 'tmux-plugins/tmux-sidebar'

Hit prefix + I to fetch the plugin and source it. You should now be able to use the plugin.

Manual Installation

Clone the repo:

$ git clone https://github.com/tmux-plugins/tmux-sidebar ~/clone/path

Add this line to the bottom of .tmux.conf:

run-shell ~/clone/path/sidebar.tmux

Reload TMUX environment:

# type this in terminal
$ tmux source-file ~/.tmux.conf

You should now be able to use the plugin.

Docs

Other goodies

  • tmux-copycat - a plugin for regex searches in tmux and fast match selection
  • tmux-resurrect - restore tmux environment after a system restart

License

MIT

tmux-sidebar's People

Contributors

bruno- avatar davidjb avatar erikw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmux-sidebar's Issues

Use [asciinema](asciinema.org) for demos

Asciinema allows you to record and embed any terminal session.
This is a way more sensible alternative to gifs (and probably youtube videos too) because of the following reasons:

  • ability to copy text
  • bandwidth usage
  • easy markdown embedding

Installing with TPM: '~/.tmux/plugins/tpm/tpm' returned 1

I'm using Tmux 2.0 on Ubuntu 14.04

I tried to install tmux-sidebar with TPM:

set -g @plugin 'tmux-plugins/tmux-sidebar'

However, when I tell TPM to install it's dependencies, it fails with the following error:

'~/.tmux/plugins/tpm/tpm' returned 1

If I remove tmux-sidebar from my .tmux.conf, it works just fine.

More generic sidebar?

Any way to make this plugin more generic? I'd love to have a pop-out sidebar that I can use to save notes, run other commands, etc that gets shared with other windows. Maybe something along the lines of embedding another tmux window inside each sidebar, connected to a single instance of nano -t $HOME/.tmux-sidebar-note.txt?

I don't know a whole lot about tmux, I actually mostly use byobu with a few tmux settings for command shortcuts and adjusting the colors, so if this is just a simple tmux command/setting that doesn't require a plugin, please excuse my ignorance.

No way to configure which files are displayed

There's no way to configure the parameters sent to the tree command internally, so there's no way to hide files or folders -- the only option is the equivalent of ls -aR, which tends to contain way more entries than you'd normally want.

Separator character (comma) for `$ARGS` conflicts with custom options

I use this plugin by replacing tree with lsd and modified less options (to display NerdFonts icons).

lsd --all --icon always --color always --size default --long --blocks size,name | tail +3
sh -c "LESSUTFCHARDEF=23fb-23fe:p,2665:p,26a1:p,2b58:p,e000-e00a:p,e0a0-e0a2:p,e0a3:p,e0b0-e0b3:p,e0b4-e0c8:p,e0ca:p,e0cc-e0d4:p,e200-e2a9:p,e300-e3e3:p,e5fa-e6a6:p,e700-e7c5:p,ea60-ebeb:p,f000-f2e0:p,f300-f32f:p,f400-f532:p,f500-fd46:p,f0001-f1af0:p less -R -L -Q -X -S --tilde"

image

ISSUE

The command lines for lsd and less include some options with listed args separated by commas, tmux-sidebar will fail because it uses comma separators in its global variables.

SOLUTION

Everything related to $ARGS in sidebar.tmux, scripts/helpers.sh and scripts/variables.sh uses comma as a separator and it should be replaced with another character. I use underscores because I know that I will not use any in those commands.

Pane auto closes as soon as I hit Prefix + Tab

As soon as I hit this prefix, I see the split show up and then immediately close. Is there anything in my conf that might be affecting this? I'm on OSX 10.9.5 with iTerm2, fish shell, tmux 1.9a, and tree installed.

Here's my conf;

# remap prefix to Control + q
set -g prefix C-s
unbind C-b
bind C-s send-prefix

# Display
set -g status-bg blue
set -g status-fg white
set -g default-terminal "screen-256color"

# Copy mode
set-option -g default-command "reattach-to-user-namespace -l fish"
setw -g mode-keys vi
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"

# Custom bindings
bind-key x kill-pane
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind v copy-mode
bind Up resize-pane -U 10
bind Down resize-pane -D 10
bind Left resize-pane -L 10
bind Right resize-pane -R 10

# Open new windows/panes with current dir
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

# Plugins
set -g @tpm_plugins "         \
  tmux-plugins/tpm            \
  tmux-plugins/tmux-open      \
  tmux-plugins/tmux-resurrect      \
  tmux-plugins/tmux-sidebar      \
"
set -g @resurrect-processes 'shh cmus weechat mutt'

# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell ~/.tmux/plugins/tpm/tpm

Not clear what it is useful for

What's the purpose of this, like if you have the directory tree, can you open a file in vim from the tree? I'm not able to do it, can you do fuzzy search? I guess no as this is just displaying the output of tree -C

Can you help me understand how you use this? what are the real uses.

Run command without pager

I had the interesting idea of running vifm (an interactive ncurses program) for a sidebar instead of a static directory mapping.

# opens `vifm` in single-pane mode, at the current directory
set -g @sidebar-tree-command 'vifm -c "only" .'

Alone, this doesn't work, because this plugin runs the command through a pager. After some experimentation in the terminal I found that piping vifm | cat made it work as expected for some reason. So I tried this in tmux:

set -g @sidebar-tree-pager 'cat'

This works perfectly and I highly recommend making it a suggestion in the README!

However there is one weird thing that caused me to open this issue. It works in seemingly every directory except my home directory. The error I get is:

'/home/ross/.tmux/plugins/tmux-sidebar/scripts/toggle.sh 'vifm -c "only" . | cat,left,40' '%0'' returned 1

Again, this only occurs in my home directory, as far as I can tell after trying in many random directories. Any ideas?

Using NNN instead of tree | Files not opening

I tried using NNN as replacement but because of the same reason as here: #19
I cannot, so I follow the fix mention there to add the following line:
set -g @sidebar-key-t 'nnn,left,60,focus'

Now I can open NNN using the C-b + t shortcut, but when it's open, I cannot open any file - even though if I open it seperately it works fine

'tree' not installed - blank sidebar

There's no indication that the tree command is required. When it's unavailable, this sidebar is simply empty. There should be some notification of such instead.

Support XDG Base Directory Specification for `SIDEBAR_DIR`

Tmux support putting the config in the XDG path $XDG_CONFIG_PATH/tmux/tmux.conf and I noticed that this plugin will still create a file $HOME/.tmux/sidebar/directory_widths.txt, thus polluting $HOME.

Background

Lately the XDG Base Directory Specification has been gaining quite a steady popularity, even though it's been around for a long time already. The basic idea is to standardize where programs put their files e.g. all config files in a certain directory. The benefits for end users are many, including:

  • No polluted $HOME/
  • Can easily grep for only config files in $XDG_CONFIG_HOME
  • Can decide where to store configurations in more complex setups (multi system setup e.g.)
  • Easily wipe state by removing $XDG_STATE_HOME or even $XDG_DATA_HOME, but without destroying and configuration files.

The first point is maybe what most end users enjoy the most though.

How

Specifically for this project, this should mean that the search for the configuration file should be done like:

  1. if $XDG_CONFIG_HOME is set, look for $XDG_CONFIG_HOME/tmux/sidebar/directory_widths.txt
  2. elseif $XDG_CONFIG_HOME is unset, use the default value for the envvar which is $HOME/.config. Thus, the config file to look for is at $HOME/.config/tmux/sidebar/directory_widths.txt
  3. else fall-back to current legacy $HOME/.tmux/sidebar/directory_widths.txt

The first two steps to can be codifed in bash like:
${XDG_CONFIG_HOME:-$HOME/.config}/amethyst/amethyst.yml

I noticed that variables.sh set base dir path as an envvar $SIDEBAR_DIR:

SIDEBAR_DIR="$HOME/.tmux/sidebar"

Maybe it's possible to override this value as a workaround until full XDG support is added? ๐Ÿค”

Enabling colourisation of tree output requires forcing

I'm using the latest sidebar from Git and finding that the output in the sidebar isn't coloured, whereas if I run tree (version 1.7.0) directly, it is coloured. I added:

set -g @sidebar-tree-command 'tree -C'

to my tmux.conf and now it's forcing coloured output, which works in the sidebar. I'm not sure what the difference here is; apparently tree considers $LS_COLORS, which is already set in my environment.

Is this a bug / should coloured output be the standard? If not, I'd suggest adding the config line to the FAQs.

Tree disappeared

The sidebar tree was showing up fine; I was trying to colorize the tree using set -g @sidebar-tree-command 'tree -C' and now the trees do not show up. The pane is blank. I can open up the help menu using h, but no tree. I do not understand how to reproduce this either. System: Debian 5.10.92-1, tmux 3.1c with darcula theme.

Bug: side bar shows file system from root on macOS

I installed tmux-sidebar through tpm and it is showing me the root file system (from /) rather than my current working directory which is ~. How do I fix this? Is there some refresh command that I'm missing or something?

Refresh on directory change

When changing a directory, I need to close and reopen the sidebar.

Is there a way to make it update itself automatically when the directory is changed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.