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

Feat (docker): add docker aliases #1147

Merged
merged 10 commits into from
Apr 13, 2017

Conversation

akarzim
Copy link
Contributor

@akarzim akarzim commented May 16, 2016

Add some concise aliases for docker, docker-machine and docker-compose.

AFAIK, theses aliases will not shadow other system commands or presto’s module aliases.

@malikoth
Copy link
Contributor

Can I suggest a few more?

alias dki='docker images'
alias dkin='docker inspect'
alias dkpsa='docker ps -a'
alias dkR='docker run -it --rm'
alias dkRe='docker run -it --rm --entrypoint /bin/bash'

# Clean up exited containers
alias dkcc='docker rm $(docker ps -a | grep Exited | awk '"'"'{ print $1 }'"'"')'

# Clean up dangling images
alias dkci='docker rmi $(docker images -f dangling=true -q)'

@malikoth
Copy link
Contributor

This PR is absolutely essential, @sorin-ionescu !!!

@jeffwidman
Copy link
Collaborator

See also #863 and https://github.com/felixr/docker-zsh-completion (which has instructions for installing into prezto)

@saoula
Copy link

saoula commented Sep 22, 2016

May I also suggest

alias dkce='docker-compose exec'

@akarzim
Copy link
Contributor Author

akarzim commented Dec 14, 2016

🙏 Thanks @malikoth ! I added your proposals.

I've renamed the proposed cleanup aliases to avoid conflicts with docker-compose (dkc) aliases.

@akarzim
Copy link
Contributor Author

akarzim commented Dec 14, 2016

🙏 Thanks @saoula ! I added your proposal.

@malikoth
Copy link
Contributor

malikoth commented Jan 31, 2017

What about dkcR='docker-compose run --rm'?

@akarzim
Copy link
Contributor Author

akarzim commented Feb 1, 2017

@malikoth it's already there in my standalone repository. Prezto seems in standby and @sorin-ionescu is not reactive, so I switched to zplug. You can check my up to date docker aliases here: https://github.com/akarzim/zsh-docker-aliases

@malikoth
Copy link
Contributor

malikoth commented Mar 1, 2017

Thanks for the information that you've switched to zplug. After looking at their README, it looks like I'm switching to zplug too! (May take me awhile though. /sigh)

@facastagnini
Copy link
Collaborator

Hey guys this repo is not being maintained, see #1239

The community fork is here https://github.com/zsh-users/prezto, please move this issue to zsh-users and we will be able to help you!

zsh-users is an organization dedicated to host Zsh community projects and therefore became the rational home for a community maintained version of prezto.

@belak
Copy link
Collaborator

belak commented Apr 5, 2017

It looks like something happened with this PR and it may have been rebased against zsh-users/prezto... so there's quite a few unrelated information in here. If you'd like this to be merged in, it would first have to be written against this repo rather than the fork.

@akarzim akarzim force-pushed the modules/docker branch 2 times, most recently from 775cfac to e3fedfd Compare April 5, 2017 07:28
@akarzim
Copy link
Contributor Author

akarzim commented Apr 5, 2017

@Belack Done.

@belak
Copy link
Collaborator

belak commented Apr 5, 2017

I appreciate your willingness to fix this, but I think you may have misunderstood... somehow there are commits from the zsh-users/prezto repo showing up in this pull request... if you look at the commits, it says there are over 100 (along with a ton of unrelated changes and conflicts). This shouldn't be based off the zsh-users repo, just this one.

@akarzim
Copy link
Contributor Author

akarzim commented Apr 5, 2017

My bad. Something went wrong. It seems to be OK right now.


# Return if requirements are not found.
if (( ! $+commands[docker] )); then
return 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use two-space tabs to match with the rest of the project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Done.

if [[ -L default ]]; then
eval $(rm -f default)
elif [[ -d default ]]; then
echo "A default manchine already exists. Abort."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. Should be machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}

#
# Aliases
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a ton of aliases here. Could you do something similar to what the git module does? Aliases go in alias.zsh and init.zsh calls source "${0:h}/alias.zsh" to load it.

@belak
Copy link
Collaborator

belak commented Apr 13, 2017

Also (and I realize this is a much larger task than the small ones given in the review) would it be worthwhile reorganizing the aliases and perhaps changing them to be similar in style to the git aliases?

In the git module, it focuses around a single letter (g) followed by an action/object (as an example c is commit) followed by what's actually being done. So gp is git push and gpF is git push --force (it uses a capital letter because it's potentially destructive).

Git is also aliased to just g. Is there any reason Docker couldn't be aliased to just d rather than dk? Are there conflicts with existing commands? If not, I feel like at this point docker may be important enough to warrant a single letter.

When a module gets this many aliases, it can be worthwhile to think carefully about what's worth including and what isn't, so we can avoid some of the alias hell that has been discussed in many oh-my-zsh issues.

I'd personally like to see similar aliases for docker. As an example, dck could be kill container (meant as docker container kill) rather than dkk for docker kill. This is, of course, just an example. There may be better ways to do this... and I'd probably be alright with merging this in... I'd just like to do everything possible to avoid confusing aliases if at all possible.

Does anyone else have opinions on this? I realize this may be a bit more than most people wanted to read, but I'd be happy to hear what everyone else thinks as well.

EDIT: And please don't take this as what needs to be done. I'd just like to get a discussion started. There may be more value in keeping the aliases closely matched to their original full commands as well.

@akarzim
Copy link
Contributor Author

akarzim commented Apr 13, 2017

@belak in fact, I tried to match git aliases pattern: dk for docker, dkc and dkm for docker-compose and docker-machine, adding more letters for more precise aliases. A capital letter is used for alternative commands with option, like dke vs dkE ; or subsets like like dkC, dkV, dkI.

I choosed dk because d is already an alias from the directory module, and some sub-commands based on d would overwrite system commands (ie. dc is an arbitrary precision calculator). So dk appears as the safer alias for docker.

@belak
Copy link
Collaborator

belak commented Apr 13, 2017

Alright, I'm going to merge this to a temporary branch, squash the commits, and undo the submodule changes before merging it into master, but it looks pretty much ready.

@belak belak changed the base branch from master to belak/tmp-docker April 13, 2017 10:13
@akarzim
Copy link
Contributor Author

akarzim commented Apr 13, 2017

Great ! Thank you Kaleb.

@belak belak merged commit 1aeeb42 into sorin-ionescu:belak/tmp-docker Apr 13, 2017
belak pushed a commit that referenced this pull request Apr 13, 2017
belak pushed a commit that referenced this pull request Apr 13, 2017
@belak
Copy link
Collaborator

belak commented Apr 13, 2017

Merged in 8a43331. Thanks for all your work on this!

nosyjoe added a commit to nosyjoe/prezto that referenced this pull request Apr 17, 2017
* upstream/master: (57 commits)
  Move python-info call in paradox from preexec to precmd
  Add missing alias to utility README
  Rework diff function
  Remove additional newlines in issue and pull request templates
  Add initial issue and pull request templates
  Add note to CONTRIBUTING.md about zstyle
  Add code style to CONTRIBUTING.md
  Update is-callable to also check builtins
  Fix indentation in README
  Feat (docker): add docker aliases (sorin-ionescu#1147)
  Doc (ruby): add doc on bundle clean alias
  Add bundle clean alias
  Don't use a deprecated argument as a python example
  Add note about working around preexisting runcoms
  completion: Cap max-errors at 7 to avoid hanging (sorin-ionescu#953)
  Allow syntax highlighting pattern styles (sorin-ionescu#1192)
  Feat (aliases): add aliases for git flow
  Update fasd README with basic installation information
  Remove manb from completion filename
  Ensure extendedglob is set in promptpwd
  ...
tunght13488 added a commit to tunght13488/prezto that referenced this pull request Apr 19, 2017
* upstream/master: (57 commits)
  Update ssh module for multi session hosts
  New `alias gfa=git fetch --all` for git module
  Add utility alias for pydf
  Add perl-info function & plenv subcommand aliases (sorin-ionescu#1303)
  archive: add archive function
  archive: add support for *.jar files (sorin-ionescu#1302)
  Move python-info call in paradox from preexec to precmd
  Add missing alias to utility README
  Rework diff function
  Remove additional newlines in issue and pull request templates
  Add initial issue and pull request templates
  Add note to CONTRIBUTING.md about zstyle
  Add code style to CONTRIBUTING.md
  Update is-callable to also check builtins
  Fix indentation in README
  Feat (docker): add docker aliases (sorin-ionescu#1147)
  Doc (ruby): add doc on bundle clean alias
  Add bundle clean alias
  Don't use a deprecated argument as a python example
  Add note about working around preexisting runcoms
  ...
nosyjoe added a commit to nosyjoe/prezto that referenced this pull request Apr 19, 2017
* 'master' of github.com:nosyjoe/prezto: (55 commits)
  uses nosyjoe theme instead of philipp after renaming
  disables fvm in favor of rbenv
  updates some modules
  fixes doubled username/host prompt on ssh sessions
  Move python-info call in paradox from preexec to precmd
  Add missing alias to utility README
  Rework diff function
  Remove additional newlines in issue and pull request templates
  Add initial issue and pull request templates
  Add note to CONTRIBUTING.md about zstyle
  Add code style to CONTRIBUTING.md
  Update is-callable to also check builtins
  Fix indentation in README
  Feat (docker): add docker aliases (sorin-ionescu#1147)
  Doc (ruby): add doc on bundle clean alias
  Add bundle clean alias
  Don't use a deprecated argument as a python example
  Add note about working around preexisting runcoms
  completion: Cap max-errors at 7 to avoid hanging (sorin-ionescu#953)
  Allow syntax highlighting pattern styles (sorin-ionescu#1192)
  ...
tenebrousedge pushed a commit to tenebrousedge/prezto that referenced this pull request Apr 20, 2017
onshi pushed a commit to onshi/prezto that referenced this pull request May 5, 2017
drpebcak pushed a commit to drpebcak/prezto that referenced this pull request May 15, 2017
sgtsquiggs pushed a commit to sgtsquiggs/prezto that referenced this pull request May 16, 2017
jdsutherland pushed a commit to jdsutherland/prezto that referenced this pull request May 19, 2017
esebastian pushed a commit to esebastian/prezto that referenced this pull request May 23, 2017
Raimondi pushed a commit to Raimondi/prezto that referenced this pull request Jun 20, 2017
eduardolundgren pushed a commit to eduardolundgren/prezto that referenced this pull request Jul 8, 2017
henrydobson pushed a commit to henrydobson/prezto that referenced this pull request Jul 26, 2017
pfista pushed a commit to pfista/prezto that referenced this pull request Nov 21, 2018
josh-h pushed a commit to josh-h/prezto that referenced this pull request Dec 17, 2018
lalonde pushed a commit to lalonde/prezto that referenced this pull request Feb 28, 2019
jgosmann pushed a commit to jgosmann/prezto that referenced this pull request Nov 1, 2019
rooney pushed a commit to rooney/prezto that referenced this pull request Aug 19, 2020
RIT80 pushed a commit to RIT80/prezto that referenced this pull request Jan 25, 2022
RIT80 added a commit to RIT80/prezto that referenced this pull request Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants