-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option for preamble before shdo scripts #200
base: master
Are you sure you want to change the base?
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is motivating this example? :Shdo buffer already automatically sets (:lcd) its local-directory to the Dirvish directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three reasons:
- Using something like 'autochdir' (Allow autochdir #19) or
au BufReadPost * silent! cd %:p:h
changes the shdo script cwd. In the latter case, I could block it but would have to block every temp script (*.tmp.bat
or$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 cangf
on the path since using-
brings me to $TEMP (as expected).
2fc4551
to
90428be
Compare
I want all of my scripts to start in the current dirvish working directory, so I use the example from the doc: let g:dirvish_shdo_before = '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.
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 |
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.