#+TITLE: Dired Sidebar

[[https://github.com/jojojames/dired-sidebar/actions/workflows/ci.yml][file:https://github.com/jojojames/dired-sidebar/actions/workflows/ci.yml/badge.svg]]
[[https://melpa.org/#/dired-sidebar][file:https://melpa.org/packages/dired-sidebar-badge.svg]]
[[https://stable.melpa.org/#/dired-sidebar][file:https://stable.melpa.org/packages/dired-sidebar-badge.svg]]
[[https://elpa.gnu.org/packages/dired-sidebar.html][file:https://elpa.gnu.org/packages/dired-sidebar.svg]]


* Screenshots
  With [[https://github.com/jojojames/vscode-icon-emacs][VsCode Icons]] &
  [[https://github.com/syl20bnr/spacemacs-theme][Spacemacs Light]]
  [[./screenshots/vscode.png]]

  With [[https://github.com/jtbm37/all-the-icons-dired][All the Icons]] &
  [[https://github.com/sellout/emacs-color-theme-solarized][Solarized Light]]
  [[./screenshots/one.png]]

  With Arrows &
  [[https://github.com/anandpiyer/seoul256-emacs][Seoul-256]]
  [[./screenshots/arrows.png]]

  With Text UI &
  [[https://github.com/hlissner/emacs-doom-themes][Doom Peacock]]
  [[./screenshots/tui.png]]

* Installation
** Melpa
   I recommend using [[https://github.com/jwiegley/use-package][use-package]].

   #+begin_src emacs-lisp :tangle yes
(use-package dired-subtree
  :commands (dired-subtree-toggle dired-subtree-cycle)
  :config
  (setq dired-subtree-line-prefix " ")
  (setq dired-subtree-use-backgrounds nil))
(use-package dired-sidebar
  :ensure t
  :commands (dired-sidebar-toggle-sidebar))
   #+end_src
** Minimal Bootstrap using Git
   #+begin_src sh :tangle yes
   git clone https://github.com/jojojames/dired-sidebar
   cd dired-sidebar
   pwd # [Put this in load path.]

   git clone https://github.com/Fuco1/dired-hacks
   cd dired-hacks
   pwd # [Put this in load path.]
   #+end_src

   Add config to Emacs:
   #+begin_src emacs-lisp :tangle yes
   (add-to-list 'load-path "path from pwd")
   (require 'dired-sidebar)
   M-x dired-sidebar-toggle-sidebar
   #+end_src
* My Settings
  #+begin_src emacs-lisp :tangle yes

(use-package dired-subtree
  :commands (dired-subtree-toggle dired-subtree-cycle)
  :config
  (setq dired-subtree-line-prefix " ")
  (setq dired-subtree-use-backgrounds nil))

(use-package dired-sidebar
  :bind (("C-x C-n" . dired-sidebar-toggle-sidebar))
  :ensure t
  :commands (dired-sidebar-toggle-sidebar)
  :init
  (add-hook 'dired-sidebar-mode-hook
            (lambda ()
              (unless (file-remote-p default-directory)
                (auto-revert-mode))))
  :config
  (push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
  (push 'rotate-windows dired-sidebar-toggle-hidden-commands)

  (setq dired-sidebar-subtree-line-prefix "__")
  (setq dired-sidebar-theme 'vscode)
  (setq dired-sidebar-use-term-integration t)
  (setq dired-sidebar-use-custom-font t))
  #+end_src

  For configuration, I recommend looking at the defcustoms in ~dired-sidebar.el~.

  Sidebar can also be toggled together with [[https://github.com/jojojames/ibuffer-sidebar][ibuffer-sidebar]].

  #+begin_src emacs-lisp :tangle yes
(defun sidebar-toggle ()
  "Toggle both `dired-sidebar' and `ibuffer-sidebar'."
  (interactive)
  (dired-sidebar-toggle-sidebar)
  (ibuffer-sidebar-toggle-sidebar))
  #+end_src

* Features
** Dired
   As a result of using ~dired~ as a base, many features and functionality already
   exist in a polished state with standard keybindings an Emacs user will already
   be familiar with. Because of this ~dired-sidebar~'s codebase can stay small and lean,
   serving as the glue to several different packages.
** Multiple Frames
   Sidebar may be used in multiple frames with each frame having its own sidebar state.
** File Following
   Sidebar can be periodically set to refresh to reflect the currently selected file.

   When Sidebar is initially opened, folders will be automatically expanded to
   point to the current file.
** Mouse Support
   Close/expand folders and open files with left click.
** Projectile
   Integrated with [[https://github.com/bbatsov/projectile][projectile]].

   Sidebar opens up with ~projectile~'s root as sidebar's root.
   Sidebar will also automatically update its root when projectile changes root.
** Dired Subtree
   Integrated with [[https://github.com/Fuco1/dired-hacks][dired-subtree]].

   Close and expand folders with dired-subtree.
** Ace Window
   Integrated with [[https://github.com/abo-abo/ace-window][ace-window]].

   Select the window files are to be opened in.
** File Watching / Automatic Refresh
   ~dired-sidebar~ will automatically update to reflect file changes as well as
   after a few special commands.

   Take a look at ~dired-sidebar-refresh-on-special-commands~ and
   ~dired-sidebar-special-refresh-commands~ for more configuration.
** All The Icons
   Can use [[https://github.com/jtbm37/all-the-icons-dired][all-the-icons]] for icons.
** Nerd Icons
Can use [[https://github.com/rainstormstudio/nerd-icons-dired][nerd-icons]].

#+begin_src emacs-lisp :tangle yes
(use-package nerd-icons :defer t)
(use-package nerd-icons-dired
  :commands (nerd-icons-dired-mode))
(setq dired-sidebar-theme 'nerd-icons)
#+end_src
** Terminal Support
   Icons will be replaced with "+" and "-" to indicate folder nesting in terminals.
** Evil
   Keys are bound for [[https://github.com/emacs-evil/evil][evil]].
** Magit
   Integrated with [[https://github.com/magit/magit][magit]].

   Toggling the sidebar in ~magit~ sets sidebar's root at ~magit~'s directory.
   If point was on a file in ~magit~, point at the file upon opening ~dired-sidebar~.
** IBuffer
   ~dired-sidebar~ will open sidebar and point at buffer's file.
* Running Tests
  #+begin_src sh :tangle yes
  cask
  make compile
  make lint
  make test
  #+end_src
* Help Wanted
  Look at issues page! :)
