Skip to content
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

Run custom commands in interactive shell #4047

Open
felixschndr opened this issue Nov 7, 2024 · 4 comments
Open

Run custom commands in interactive shell #4047

felixschndr opened this issue Nov 7, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@felixschndr
Copy link

Is your feature request related to a problem? Please describe.
When a custom command is specified in the config it runs it with bash -c "<command>". I'd like this shell to be interactive to be able to run shell aliases which lie in my .bashrc.

Describe the solution you'd like
Run bash -ic "<command">

Describe alternatives you've considered
Currently I am adding a layer of bash:

  - key: <c-d>
    context: "localBranches, remoteBranches"
    command: bash -ic "git_delete_old_branches"
    stream: true

which runs bash -c bash -ic "git_delete_old_branches"

Additional context
Maybe make this a config variable?

I tried to go through the source code to check where the bash -c (without -i) is invoked but was a bit overwhelmed by the search results. If someone could show me where this is done I'd take a crack at creating a PR.

@felixschndr felixschndr added the enhancement New feature or request label Nov 7, 2024
@felixschndr felixschndr changed the title Make custom command interactive Run custom commands in interactive shell Nov 7, 2024
@aaronjconway
Copy link

NewShell() in the /oscommands/cmd_obj_builder.go

I just open up another pane, do work then hop back.

@felixschndr
Copy link
Author

felixschndr commented Nov 11, 2024

There is also NewInteractiveShell()

func (self *CmdObjBuilder) NewInteractiveShell(commandStr string) ICmdObj {
. We could just run this function instead, right?

@felixschndr
Copy link
Author

We could just run this function instead, right?

If so I am not able to find where this function call has to be changed

@yam-liu
Copy link
Contributor

yam-liu commented Nov 15, 2024

There are some thoughts shared in #3299 (comment). Using -i for custom commands is not ideal due to performance concerns.

Since custom commands are typically one-off configurations in config.yml, it should be fine to write the original command directly. However, for shell commands that you frequently type and reuse, using -i is reasonable so that you can reach your aliases etc..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants