Skip to content

Commit

Permalink
Add base commands
Browse files Browse the repository at this point in the history
  • Loading branch information
umatare5 committed Jan 6, 2022
1 parent 060063c commit 1d94a54
Show file tree
Hide file tree
Showing 25 changed files with 175 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"MD013": false,
"MD033": false
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# fish-my-functions

Functions in my fish shell.

<a href="https://fishshell.com/">
<img src="https://badgen.net/badge/fish-shell/plugin?icon=terminal" alt="fish-shell plugin">
</a>

<a href="https://github.com/umatare5/fish-my-functions/blob/master/LICENSE">
<img src="https://badgen.net/github/license/umatare5/fish-my-functions" alt="license">
</a>

## 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` |
Empty file added completions/.keep
Empty file.
3 changes: 3 additions & 0 deletions functions/alogin.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function alogin --wraps='aws sso login --profile' --description 'alias alogin=aws sso login --profile'
aws sso login --profile $argv;
end
4 changes: 4 additions & 0 deletions functions/atoken.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/bcon.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/chrome.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/dc.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function dc --wraps='docker container' --description 'alias dc=docker container'
docker container $argv;
end
3 changes: 3 additions & 0 deletions functions/di.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function di --wraps='docker image' --description 'alias di=docker image'
docker image $argv;
end
3 changes: 3 additions & 0 deletions functions/g.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function g --wraps=git --description 'alias g=git'
git $argv;
end
3 changes: 3 additions & 0 deletions functions/ga.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function ga --wraps='git add' --description 'alias ga=git add'
git add $argv;
end
3 changes: 3 additions & 0 deletions functions/gb.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function gb --wraps='git branch' --description 'alias gb=git branch'
git branch $argv;
end
3 changes: 3 additions & 0 deletions functions/gci.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function gci --wraps='git commit -m' --description 'alias gci=git commit -m'
git commit -m $argv;
end
3 changes: 3 additions & 0 deletions functions/gco.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function gco --wraps='git checkout' --description 'alias gco=git checkout'
git checkout $argv;
end
3 changes: 3 additions & 0 deletions functions/gd.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function gd --wraps='git diff' --description 'alias gd=git diff'
git diff $argv;
end
3 changes: 3 additions & 0 deletions functions/gip.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/glogin.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/gp.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function gp --wraps='git push origin HEAD' --description 'alias gp=git push origin HEAD'
git push origin HEAD $argv;
end
3 changes: 3 additions & 0 deletions functions/gtoken.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/nstats.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/o.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function o --wraps=open --description 'alias o=open'
open $argv;
end
3 changes: 3 additions & 0 deletions functions/wlan.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/wlog.fish
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions functions/wshark.fish
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1d94a54

Please sign in to comment.