-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Feature request: Shell alias expansion #2
Comments
I've closed #9, since it was a duplicate of this one. |
Apparently if we do this:
It starts working with aliases: |
True, but this has the same shortcoming as mentioned here: https://unix.stackexchange.com/a/25329
|
To solve this, should I parse the file which is defining the aliases (e.g. bashrc or zshrc)? I haven't come up with another good way to do it. |
The command could be called via the shell:
This could be considered insecure though, so maybe it could be opt-in via flag? |
Yep, that would be my suggestion too! Get the shell and execute the command within that shell. Should work for the most used shells at least. |
Thank you! I understood. |
@croissong @davidandradeduarte I've added new options Please specify your aliases in Define you aliases in .profile alias ll="ls -l" Run viddy viddy --shell-options "--login" ll How do you think this solution? To run on the shell interactive mode, we should run a command on PTY. The |
It's good to at least have the option, but I don't think most users will maintain a separate file for aliases just to use in viddy :/ We can get them easily with: alias | xargs -I {} echo "alias {}" > ~/.profile But it's hard to maintain. This will not work for me right now tho, because you're only getting the first string from the alias.
only gets If I change it to
with quotes, it works. On another note, I've tried the viddy --shell "/bin/zsh" ll and doesn't seem to work either. Maybe I'm doing something wrong, haven't looked at the code yet. Edit: alias | parallel -I {} echo "alias {}" > ~/.profile using |
I think this is invalid alias definition. The quotation is necessary.
When you want to use alias, you should specify I think maintaining alias file is easy. Define alias in .alias
Load that from .profile and rc file (.bashrc) too
|
@sachaos Thanks for the update! I wasn't aware of the implications of using interactive mode outside of a pty, and to be honest, i still don't fully understand it (and how it can be solved). But as far as i can tell, running the shell in non-interactive mode still provides all the other advantages of spawning a shell (e.g. pipes work), so i am perfectly happy with this solution 👍 |
Thank you for trying out. I couldn't get the output from interactive mode shell. |
I would like to close this issue. If there are other problems, feel free to open or comment here. :) |
My alias file is little complex, so I use this function. vd() {
viddy -d -n 1 --shell zsh "$(which $1 | cut -d' ' -f 4-)"
}
# ex:
alias kgp="kubectl get pod" After I can run like this $ vd kgp caution: but vd can't handle functoin. |
In fish this function works for me function vdy --description 'modern watch'
viddy -d -n 2 --shell fish $argv[1..-1]
end |
Thanks to this suggestion by @lirlia, I found a solution that works for me in zsh. vd k get pods Many people have aliased We can do this by setting an alias like the following: alias vd=(){viddy -d -n 1 --shell zsh "$(which $1 | cut -d' ' -f 4-)${@:2}";}
|
I am not sure if this tool is still being developed, but in case it is - is there a way to add I assume it should be here: https://github.com/sachaos/viddy/blob/master/snapshot.go#L117-L118. The idea behind it is to run viddy with |
@Shaked This tool is alive. In this case we should add that feature as experimental option. The PR is welcome. |
@sachaos thanks for the quick reply! I have started playing with it but it seems like my idea doesn't work. Only -ci would and that seems like a problem with viddy. I don't mind filing a PR but I would have to find a way to make this work first :) |
It would be nice to be able to use aliases in the watch commands :)
The text was updated successfully, but these errors were encountered: