jesseduffield / lazygit

simple terminal UI for git commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Command Keybindings - PlaceHolderValues: SelectedFile exists -> add SelectedDir

alexn-s opened this issue · comments

commented

Is your feature request related to a problem? Please describe.

I am using a pnpm monorepo and have some automatic pipelines with conventional commit (eg. using the name from the project in the git repo in the commit). In order for that to work I must automatically navigate/ cd into the project and run the pipeline from there. Currently it only works with SelectedFile.name to get the path and proceed with it.

Describe the solution you'd like

Add SelectedDir to the PlaceHolderValues so it is not required to select a file

Examples

example CURRENT command
config.yml

customCommands
  - key: "y"
    command: "powershell.exe -noProfile C:/Users/.../AppData/Roaming/lazygit/scripts/git-cz.ps1 {{.SelectedFile.Name}}"
    context: "files"
    loadingText: "..."
    subprocess: true

example PREFERRED command
config.yml

customCommands
  - key: "y"
    command: "powershell.exe -noProfile C:/Users/.../AppData/Roaming/lazygit/scripts/git-cz.ps1 {{.SelectedDir.Name}}"
    context: "files"
    loadingText: "..."
    subprocess: true

would a SelectedPath option suffice? Or do you want something specifically for the selected directory of the current file?

commented

selected path would be awesome.

currently i convert the SelectedFile.Name path to a directory path again anyway,
because cd obviously only works for a dir path

love your work on lazygit. really appreciate it 💖

would a SelectedPath option suffice? Or do you want something specifically for the selected directory of the current file?

How would SelectedPath differ from the SelectedFile, would it be absolute instead of relative, or?

The SelectedDir might come in handy for accepting all hunks from a certain source for the selected directory, as mentioned here.

SelectedFile contains an actual File struct so you can access public fields on it, but if you've selected a directory then SelectedFile will be nil. I'd make the SelectedPath use the same form of path as whatever SelectedFile currently uses (I assume relative). If we need an absolute form we can introduce SelectedAbsPath.

Does introducing SelectedDir actually give us anything beyond the path itself?

Yeah, no, SelectedPath would offer more than enough, I didn't have a clear enough picture of what would SelectedPath encompass, but now it's cleared up!

Uhhh... we already have SelectedPath, it's just not documented? Lookie here

	SelectedSubCommit      *models.Commit
	SelectedFile           *models.File
--->    SelectedPath           string
	SelectedLocalBranch    *models.Branch
	SelectedRemoteBranch   *models.RemoteBranch

I'll add it to the README.

Oh my god that's embarrassing!

ezoic increase your site revenue