Skip to content

Commit f0e50ad

Browse files
hinogicljoly
andcommitted
Add an option to easily support PowerShell
Co-authored-by: Clément Joly <7347374+cljoly@users.noreply.github.com>
1 parent 2b4ad95 commit f0e50ad

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,17 @@ Transform the result paths into relative ones with this value as the base dir.
187187

188188
Default value: `vim.fn.getcwd()`
189189

190-
##### `fd_opts`
190+
##### `fd_opts` & `find_exec_opts`
191191

192-
**This is a relatively advanced option that you should use with caution. There is no guarantee that a particular set of options would work the same across multiple versions**
192+
**These are relatively advanced options that you should use with caution. There is no guarantee that a particular set of options would work the same across multiple versions of the plugin**
193193

194-
This passes additional options to the command `fd` that generates the repository list. It is inserted like so:
194+
This passes additional exec options to the command `fd` that generates the repository list. It is inserted like so:
195195

196196
```
197-
fd [set of default options] [fd_opts] --exec [some default command] [pattern] …
197+
fd [set of default options] [fd_opts] --exec [find_exec_opts] [pattern] …
198198
```
199199

200-
##### Example
200+
###### `fd_opts` Example
201201

202202
Let’s say you have a git repository `S` inside another git repository `M` (for instance because of [#5](https://github.com/cljoly/telescope-repo.nvim/issues/5)), but `S` is in a directory that’s ignored in the `.gitignore` in `M`. `S` wouldn’t appear in the Telescope list of this extension by default, because it is ignored (`.gitignore` are taken into account by default).
203203

@@ -207,7 +207,23 @@ To avoid taking into account the `.gitignore`, we need to pass `--no-ignore-vcs`
207207
:lua require'telescope'.extensions.repo.list{fd_opts={'--no-ignore-vcs'}}
208208
```
209209

210-
This will list `M` and `S` in the Telescope output! The downside is that listing repositories will be a little longer, as we don’t skip the git-ignored files anymore.
210+
This will list `M` and `S` in the Telescope output. The downside is that listing repositories will be a little longer, as we don’t skip the git-ignored files anymore.
211+
212+
###### `fd_exec_opts` Example
213+
214+
This is mainly to accommodate different OS shells like PowerShell on windows.
215+
216+
Let’s say you try to use telescope repo in windows powershell, then the command could be something like this to make it work
217+
218+
```
219+
fd --exec powershell /C "echo {//}" ; ^\.git$
220+
```
221+
222+
To use an equivalent command with the plugin, run:
223+
224+
```
225+
:lua require'telescope'.extensions.repo.list{fd_exec_opts={'powershell /C "echo {//}"'}}
226+
```
211227

212228
##### `search_dirs`
213229

@@ -294,7 +310,7 @@ if you encounter any problems. If it’s not the case by default, you should aut
294310

295311
Options are the similar to `repo list`, bearing in mind that we use `locate` instead of `fd`. Note that the following `list` options are not supported in `cached_list`:
296312

297-
* `fd_opts`, as we don’t use `fd` with `cached_list`,
313+
* `fd_opts` and `fd_exec_opts`, as we don’t use `fd` with `cached_list`,
298314
* `search_dirs`, as `locate` does not accept a directory to search in.
299315

300316
#### Examples

lua/telescope/_extensions/repo/list.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ M.prepare_command = function(opts)
1919
-- .git file in them.
2020
local find_repo_opts = { "--hidden", "--case-sensitive", "--absolute-path" }
2121
local find_user_opts = opts.fd_opts or {}
22-
local find_exec_opts = { "--exec", "echo", [[{//}]], ";" }
22+
local find_exec_opts = opts.fd_exec_opts or { "--exec", "echo", [[{//}]], ";" }
2323

2424
-- Expand '~'
2525
local search_dirs = {}

0 commit comments

Comments
 (0)