Skip to content

Commit

Permalink
feat: add abbrs from omz
Browse files Browse the repository at this point in the history
  • Loading branch information
Asim-Tahir committed Jan 14, 2024
0 parents commit e5f0750
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

charset = utf-8
end_of_line = lf
tab_width = 1
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2023 Asim Tahir

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<img src="https://cdn.rawgit.com/oh-my-fish/oh-my-fish/e4f1c2e0219a17e2c748b824004c8d0b38055c16/docs/logo.svg" align="left" width="192px" height="192px"/>
<img align="left" width="0" height="192px" hspace="10"/>

### `docker-compose.fish`

> `Docker Compose` plugin for [Oh My Fish][omf] and [Fisher][fisher],
> based loosely on the [Oh My Zsh][omz]'s [Docker Compose Plugin][omz-docker-compose-plugin]
[![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square)](/LICENSE)
[![Fish Shell v3.6.0](https://img.shields.io/badge/fish-v3.6.0-007EC7.svg?style=flat-square)](https://fishshell.com)
[![Oh My Fish Framework](https://img.shields.io/badge/Oh%20My%20Fish-Framework-007EC7.svg?style=flat-square)][omf]

<br/>

## Install

[Oh My Fish][omf]:

```sh
omf install https://github.com/Asim-Tahir/docker-compose.fish
```

[Fisher][fisher]:

```sh
fisher install Asim-Tahir/docker-compose.fish
```

## Abbreviations Usage

After installing the [`docker-compose.fish`][repo] plugin, can inspect the abbreviations with the following command:

```sh
abbr --show | grep dcupdb
```

> [!NOTE]
> For all abbreviations, if the `docker compose` command is available, use `docker compose`, otherwise use `docker-compose`.
### Up

| Abbreviation | Command |
| ------------ | ------------------------------- |
| `dcup` | `docker compose up`  |
| `dcupb` | `docker compose up --build`  |
| `dcupd` | `docker compose up -d`  |
| `dcupdb` | `docker compose up -d --build`  |

### Down

| Abbreviation | Command |
| ------------ | --------------------- |
| `dcdn` | `docker compose down` |

### Logs

| Abbreviation | Command |
| ------------ | --------------------------------- |
| `dcl` | `docker compose logs` |
| `dclf` | `docker compose logs -f` |
| `dclF` | `docker compose logs -f --tail 0` |

### Lifecycle

| Abbreviation | Command |
| ------------ | ------------------------ |
| `dcstart` | `docker compose start` |
| `dcstop` | `docker compose stop` |
| `dck` | `docker compose kill` |
| `dcrestart` | `docker compose restart` |

### Run Command

| Abbreviation | Command |
| ------------ | --------------------- |
| `dce` | `docker compose exec` |
| `dcr` | `docker compose run` |

### Everything Else

| Abbreviation | Command |
| ------------ | ---------------------- |
| `dco` | `docker compose` |
| `dcb` | `docker compose build` |
| `dcps` | `docker compose ps` |
| `dcrm` | `docker compose rm` |
| `dcpull` | `docker compose pull` |

# Credit

Base structure heavily inspired from [`jhillyerd/plugin-git`](https://github.com/jhillyerd/plugin-git). Thanks for the amazing plugin.

# License

[MIT][license] © [Asim Tahir][author]

[author]: https://github.com/Asim-Tahir
[repo]: https://github.com/Asim-Tahir/docker-compose.fish
[license]: https://opensource.org/licenses/MIT
[omz]: https://github.com/ohmyzsh/ohmyzsh
[omz-docker-compose-plugin]: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/docker-compose/
[omf]: https://github.com/oh-my-fish/oh-my-fish
[fisher]: https://github.com/jorgebucaran/fisher
[license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square
7 changes: 7 additions & 0 deletions conf.d/docker-compose.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Fisher initialization
# protected as omf also tries to run it.
set -q fisher_path; or set -l fisher_path $__fish_config_dir
if test -f $fisher_path/functions/_docker-compose.init.fish
source $fisher_path/functions/_docker-compose.init.fish
_docker-compose.init
end
37 changes: 37 additions & 0 deletions functions/_docker-compose.abbrs.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function _docker-compose.abbrs -d "Initialize Docker Compose abbreviations"
set dccmd (docker compose version > /dev/null 2>&1 && echo 'docker compose' || echo 'docker-compose')

abbr -a -g dco $dccmd

# Up
abbr -a -g dcup $dccmd up
abbr -a -g dcupb $dccmd up --build
abbr -a -g dcupd $dccmd up -d
abbr -a -g dcupdb $dccmd up -d --build

# Down
abbr -a -g dcdn $dccmd down

# Logs
abbr -a -g dcl $dccmd logs
abbr -a -g dclf $dccmd logs -f
abbr -a -g dclF $dccmd logs -f --tail 0

# Lifecycle
abbr -a -g dcstart $dccmd start
abbr -a -g dcstop $dccmd stop
abbr -a -g dck $dccmd kill
abbr -a -g dcrestart $dccmd restart

# Command
abbr -a -g dce $dccmd exec
abbr -a -g dcr $dccmd run

# Misc
abbr -a -g dcb $dccmd build
abbr -a -g dcps $dccmd ps
abbr -a -g dcrm $dccmd rm
abbr -a -g dcpull $dccmd pull

set -e dccmd
end
4 changes: 4 additions & 0 deletions functions/_docker-compose.init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function _docker-compose.init -d "Initialize Docker Compose plugin"
# Initialize Docker Compose abbreviations
_docker-compose.abbrs
end
10 changes: 10 additions & 0 deletions init.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Oh My Fish initialization
# $path is only defined for oh-my-fish. home-manager activates this plugin by
# adding the full path of functions/ to fish_function_path, and then sourcing
# init.fish, so let's skip sourcing _docker-compose.init.fish before calling _docker-compose.init.
set -l _docker_compose_init_path "$path/functions/_docker-compose.init.fish"
if [ -f "$_docker_compose_init_path" ];
source "$_docker_compose_init_path"
end

_docker-compose.init

0 comments on commit e5f0750

Please sign in to comment.