akinsho / toggleterm.nvim

A neovim lua plugin to help easily manage multiple terminal windows
GNU General Public License v3.0
4.06k stars 170 forks source link

feat: add the command ToggleTermBufferDir to create and/or toggle a terminal with the current buffer directory #555

Closed TimaSv-Uk closed 2 weeks ago

TimaSv-Uk commented 4 months ago

This PR introduces the :ToggleTermBufferDir command, which allows users to switch the buffer directory in the terminal. If a terminal instance with a buffer directory wasn’t already there, one is created. However, once a terminal instance is created, the buffer terminal name or direction cannot be changed.

The :TermSelect command can be used to utilize toggleterm from another buffer in the current buffer. By default, the name is set to PATH_TO_CURRENT_BUFFER and the direction is set to float. The size is taken from the setup function.

Here is an example usage of the command: :ToggleTermBufferDir name=desktop direction=horizontal

I love to use Harpoon or Telescop, and the new command allows me to quickly open Terminla after jumping to a new project. If there are any issues, I'll try to fix them.

Uploading ToggleTermBufferDir_example.mp4…

akinsho commented 4 months ago

@TimaSv-Uk thanks for the PR. In general I strongly try to avoid increasing the surface area of my plugins by adding more and more commands. In this case (apologies as I only skimmed this PR) I don't understand exactly why this is needed. A user can just run cd MY_DIR once the terminal is open. Why does this need to be a builtin command?

TimaSv-Uk commented 4 months ago

@akinsho ,Hello :),

As a university student, you’re often working on various small programs in different languages, like Python, C#, and others. It can indeed be a pain to have to navigate into the directory every time you want to run a console application, especially when you need to show and run several scripts one after another to your professor. 

This year, I participated in AdventOfCode for the first time (super fun, btw) and ran into the same issue. That’s why you thought this feature might be useful; it saved me a lot of time.

Thank you for considering my suggestion.

P.S. Should I close the PR? No hard feelings, this was my first try at open source and I appreciate the opportunity to learn.