diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..26593a2 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,4 @@ +{ + "MD013": false, + "MD033": false +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..de6e5c5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 umatare5 + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2139535 --- /dev/null +++ b/README.md @@ -0,0 +1,86 @@ +# fish-my-functions + +Functions in my fish shell. + + + fish-shell plugin + + + + license + + +## Prerequisite + +- [fish shell](https://fishshell.com/) + + | Name | Installation Guide | + | ------------------ | ------------------------------------------------------------------------------------- | + | Google Chrome | [Link](https://www.google.co.jp/chrome) | + | Docker Desktop | [Link](https://www.docker.com/products/docker-desktop) | + | Wireshark | [Link](https://www.wireshark.org/download.html) | + | AWS CLI v2 (aws) | [Link](https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/install-cliv2-mac.html) | + | Cloud SDK (gcloud) | [Link](https://cloud.google.com/sdk/docs/install) | + | nload | `brew install nload` | + +## Installation + +### [Fisher](https://github.com/jorgebucaran/fisher) + +```sh +fisher install umatare5/fish-my-functions +``` + +### [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish) + +```sh +omf install https://github.com/umatare5/fish-my-functions +``` + +## Usage + +### Application + +| Command | Description | +| ------- | ----------------- | +| o | `open` wrapper | +| chrome | Run Google Chrome | +| wshark | Run Wireshark | + +### Development + +| Command | Description | +| ------- | ------------------------------ | +| dc | `docker container` wrapper | +| di | `docker image` wrapper | +| g | `git` wrapper | +| ga | `git add` wrapper | +| gb | `git branch` wrapper | +| gci | `git commit --message` wrapper | +| gco | `git checkout` wrapper | +| gd | `git diff` wrapper | +| gp | `git push origin HEAD` wrapper | + +### Networking + +| Command | Description | +| ------- | ------------------------------------------- | +| bcon | Show SSIDs detected on your Mac | +| gip | Show your outbound global IP | +| nstats | Show wireless network interface statistics | +| wlan | Show the information of wireless connection | +| wlog | Show logs written by wireless interface | + +### AWS + +| Command | Description | +| ------- | ------------------------------ | +| alogin | `aws sso login` wrapper | +| atoken | Show tokens issued by `alogin` | + +### GCP + +| Command | Description | +| ------- | ----------------------------------------------------------- | +| glogin | `gcloud auth login` and `application-default login` wrapper | +| gtoken | Show tokens issued by `glogin` | diff --git a/completions/.keep b/completions/.keep new file mode 100644 index 0000000..e69de29 diff --git a/functions/alogin.fish b/functions/alogin.fish new file mode 100644 index 0000000..5ec6f9a --- /dev/null +++ b/functions/alogin.fish @@ -0,0 +1,3 @@ +function alogin --wraps='aws sso login --profile' --description 'alias alogin=aws sso login --profile' + aws sso login --profile $argv; +end diff --git a/functions/atoken.fish b/functions/atoken.fish new file mode 100644 index 0000000..ab5a7c0 --- /dev/null +++ b/functions/atoken.fish @@ -0,0 +1,4 @@ +function atoken --wraps=jq\ -r\ \'.region\ +\ \'\|\'\ +\ .expiresAt\'\ /\(ls\ -rt\ \|\ tail\ -n\ 1\) --wraps=jq\ -r\ \'.region\ +\ \"\|\"\ +\ .expiresAt\'\ /\(ls\ -rt\ \ \|\ tail\ -n\ 1\) --description alias\ atoken=jq\ -r\ \'.region\ +\ \"\|\"\ +\ .expiresAt\'\ /\(ls\ -rt\ \ \|\ tail\ -n\ 1\) + set AWS_CACHE_DIR ~/.aws/sso/cache + jq -r '.region + "|" + .expiresAt' /(ls -rt | tail -n 1) $argv; +end diff --git a/functions/bcon.fish b/functions/bcon.fish new file mode 100644 index 0000000..9ffe88f --- /dev/null +++ b/functions/bcon.fish @@ -0,0 +1,3 @@ +function bcon --wraps='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s' --description 'alias bcon=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s' + /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s $argv; +end diff --git a/functions/chrome.fish b/functions/chrome.fish new file mode 100644 index 0000000..daa8c9c --- /dev/null +++ b/functions/chrome.fish @@ -0,0 +1,3 @@ +function chrome --wraps='open -a /Applications/Google Chrome.app' --wraps='open -a "/Applications/Google Chrome.app"' --description 'alias chrome=open -a "/Applications/Google Chrome.app"' + open -a "/Applications/Google Chrome.app" $argv; +end diff --git a/functions/dc.fish b/functions/dc.fish new file mode 100644 index 0000000..5cab369 --- /dev/null +++ b/functions/dc.fish @@ -0,0 +1,3 @@ +function dc --wraps='docker container' --description 'alias dc=docker container' + docker container $argv; +end diff --git a/functions/di.fish b/functions/di.fish new file mode 100644 index 0000000..6c93268 --- /dev/null +++ b/functions/di.fish @@ -0,0 +1,3 @@ +function di --wraps='docker image' --description 'alias di=docker image' + docker image $argv; +end diff --git a/functions/g.fish b/functions/g.fish new file mode 100644 index 0000000..f03e351 --- /dev/null +++ b/functions/g.fish @@ -0,0 +1,3 @@ +function g --wraps=git --description 'alias g=git' + git $argv; +end diff --git a/functions/ga.fish b/functions/ga.fish new file mode 100644 index 0000000..ecdd731 --- /dev/null +++ b/functions/ga.fish @@ -0,0 +1,3 @@ +function ga --wraps='git add' --description 'alias ga=git add' + git add $argv; +end diff --git a/functions/gb.fish b/functions/gb.fish new file mode 100644 index 0000000..8354a84 --- /dev/null +++ b/functions/gb.fish @@ -0,0 +1,3 @@ +function gb --wraps='git branch' --description 'alias gb=git branch' + git branch $argv; +end diff --git a/functions/gci.fish b/functions/gci.fish new file mode 100644 index 0000000..0126b34 --- /dev/null +++ b/functions/gci.fish @@ -0,0 +1,3 @@ +function gci --wraps='git commit -m' --description 'alias gci=git commit -m' + git commit -m $argv; +end diff --git a/functions/gco.fish b/functions/gco.fish new file mode 100644 index 0000000..a484368 --- /dev/null +++ b/functions/gco.fish @@ -0,0 +1,3 @@ +function gco --wraps='git checkout' --description 'alias gco=git checkout' + git checkout $argv; +end diff --git a/functions/gd.fish b/functions/gd.fish new file mode 100644 index 0000000..292d986 --- /dev/null +++ b/functions/gd.fish @@ -0,0 +1,3 @@ +function gd --wraps='git diff' --description 'alias gd=git diff' + git diff $argv; +end diff --git a/functions/gip.fish b/functions/gip.fish new file mode 100644 index 0000000..cc73bde --- /dev/null +++ b/functions/gip.fish @@ -0,0 +1,3 @@ +function gip --wraps='curl https://ifconfig.io/host' --description 'alias gip=curl https://ifconfig.io/host' + curl https://ifconfig.io/host $argv; +end diff --git a/functions/glogin.fish b/functions/glogin.fish new file mode 100644 index 0000000..e96f749 --- /dev/null +++ b/functions/glogin.fish @@ -0,0 +1,3 @@ +function glogin --wraps='gcloud auth login && gcloud auth application-default login' --description 'alias glogin=gcloud auth login && gcloud auth application-default login' + gcloud auth login && gcloud auth application-default login $argv; +end diff --git a/functions/gp.fish b/functions/gp.fish new file mode 100644 index 0000000..aeb5180 --- /dev/null +++ b/functions/gp.fish @@ -0,0 +1,3 @@ +function gp --wraps='git push origin HEAD' --description 'alias gp=git push origin HEAD' + git push origin HEAD $argv; +end diff --git a/functions/gtoken.fish b/functions/gtoken.fish new file mode 100644 index 0000000..3042551 --- /dev/null +++ b/functions/gtoken.fish @@ -0,0 +1,3 @@ +function gtoken --wraps='sqlite3 ~/.config/gcloud/access_tokens.db="SELECT token_expiry,account_id FROM access_tokens;"' --wraps=sqlite3\ \~/.config/gcloud/access_tokens.db\ \'SELECT\ token_expiry,account_id\ FROM\ access_tokens\;\' --description alias\ gtoken=sqlite3\ \~/.config/gcloud/access_tokens.db\ \'SELECT\ token_expiry,account_id\ FROM\ access_tokens\;\' + sqlite3 ~/.config/gcloud/access_tokens.db 'SELECT token_expiry,account_id FROM access_tokens;' $argv; +end diff --git a/functions/nstats.fish b/functions/nstats.fish new file mode 100644 index 0000000..2ed3149 --- /dev/null +++ b/functions/nstats.fish @@ -0,0 +1,3 @@ +function nstats --wraps='nload devices en0 -t 1000 -u m -U G' --description 'alias nstats=nload devices en0 -t 1000 -u m -U G' + nload devices en0 -t 1000 -u m -U G $argv; +end diff --git a/functions/o.fish b/functions/o.fish new file mode 100644 index 0000000..a91c40c --- /dev/null +++ b/functions/o.fish @@ -0,0 +1,3 @@ +function o --wraps=open --description 'alias o=open' + open $argv; +end diff --git a/functions/wlan.fish b/functions/wlan.fish new file mode 100644 index 0000000..3691887 --- /dev/null +++ b/functions/wlan.fish @@ -0,0 +1,3 @@ +function wlan --wraps='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I' --description 'alias wlan=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I' + /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I $argv; +end diff --git a/functions/wlog.fish b/functions/wlog.fish new file mode 100644 index 0000000..e9cde74 --- /dev/null +++ b/functions/wlog.fish @@ -0,0 +1,3 @@ +function wlog --wraps='sudo dmesg | grep en0 | grep change | grep -e=BSSID|channel' --description 'alias wlog=sudo dmesg | grep en0 | grep change | grep -e=BSSID|channel' + sudo dmesg | grep en0 | grep change | grep -e "BSSID|channel" $argv; +end diff --git a/functions/wshark.fish b/functions/wshark.fish new file mode 100644 index 0000000..518c420 --- /dev/null +++ b/functions/wshark.fish @@ -0,0 +1,3 @@ +function wshark --wraps='open -n /Applications/Wireshark.app/' --description 'alias wshark=open -n /Applications/Wireshark.app/' + open -n /Applications/Wireshark.app/ $argv; +end