Add option for preamble before shdo scripts#200
Open
idbrii wants to merge 1 commit intojustinmk:masterfrom
Open
Add option for preamble before shdo scripts#200idbrii wants to merge 1 commit intojustinmk:masterfrom
idbrii wants to merge 1 commit intojustinmk:masterfrom
Conversation
Open
justinmk
reviewed
Jul 8, 2021
justinmk
reviewed
Jul 25, 2021
doc/dirvish.txt
Outdated
| Inserts this text at the beginning of shell scripts generated with | ||
| |:Shdo|. The current dirvish directory is inserted wherever {} appears in | ||
| |g:dirvish_shdo_before|. | ||
| To ensure scripts always cd to the current dirvish directory, you could |
Owner
There was a problem hiding this comment.
what is motivating this example? :Shdo buffer already automatically sets (:lcd) its local-directory to the Dirvish directory.
Author
There was a problem hiding this comment.
Three reasons:
- Using something like 'autochdir' (Allow autochdir #19) or
au BufReadPost * silent! cd %:p:hchanges the shdo script cwd. In the latter case, I could block it but would have to block every temp script (*.tmp.bator$TEMP/*)? - I'm not comfortable running scripts that rely on cwd. Instead of manually adding the path when doing something destructive like
:%Shdo rm {}, this option automatically makes it explicit. - Gives a nice entry point back to the directory. If I
:only, edit the script, finish with it, I cangfon the path since using-brings me to $TEMP (as expected).
2fc4551 to
90428be
Compare
Owner
|
Open to merging this since it's harmless enough, but how about making it a callback? Then the callback can modify the dirvish-generated Shdo script arbitrarily, and also add a "after" script. Something like Or alternatively, wouldn't it be natural for |
Allow users to process shdo scripts on creation. The example from the doc is especially useful with 'autochdir' so scripts start in the current dirvish working directory. Other users may tend to create scripts with arguments, want their commands to be inside a function, or output some diagnostic data. Using the same escaping that is applied on lines since that seems like the safest thing to do. dirvish_dummy_events ensures no error if users haven't setup an autocmd.
Author
|
What do you think about this autocmd version? I followed tpope/fugitive as an example for invoking the User autocmd and the docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I want all of my scripts to explicitly start in the current dirvish working
directory, so I use the example from the doc:
let g:dirvish_shdo_preamble = 'cd {}'
Other users may tend to create scripts with arguments, want their
commands to be inside a function, or output some diagnostic data.
Using the same escaping that is applied on lines since that seems like
the safest thing to do.