Skip to content

Commit

Permalink
feat: add some aliase, almost about github
Browse files Browse the repository at this point in the history
  • Loading branch information
ndxbn committed Oct 31, 2024
1 parent 9b6968e commit c199525
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions zsh/.zsh_plugin.d/alias.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,57 @@ alias grep='grep --color'
alias vim='vi'

# shorthand
alias http-server='docker run -v `pwd`:/usr/share/nginx/html:ro -p 8080:80 nginx:alpine'
alias http-server='docker run -v `pwd`:/usr/share/nginx/html:ro -p 8080:80 nginx:alpine'
alias tmp='pushd "$(TMPDIR=${HOME}/.local/tmp mktemp -d)"'
alias venv='python3 -m venv venv && source ./venv/bin/activate'
# print something
## you can get from pP that which venv is activated.
alias pP='echo ${PATH} | sed -e "s/:/\n/g"'

# GitHub tools
## "get repo" short name
alias gepo='gh repo list --json nameWithOwner --jq ".[].nameWithOwner" --no-archived | peco | xargs ghq get -p'
alias gepoo='gh repo list ndxbn-tokyo --json nameWithOwner --jq ".[].nameWithOwner" --no-archived | peco | xargs ghq get -p'
alias gepoa='gh repo list akashic-system --json nameWithOwner --jq ".[].nameWithOwner" --no-archived | peco | xargs ghq get -p'
## "cd repo" short name
alias cdpo='pushd "$(ghq root)/$(ghq list | peco)"'
## lsgh
alias ghls="gh repo list --json nameWithOwner --jq '.[].nameWithOwner' --no-archived"
## cdgh
### reason to NOT "ghcd", this command may not use GitHub API if not need.
_cdgh () {
if [[ -z ${1} ]]
then
local repo_name="$(ghq list | peco --select-1)"
else
local repo_name="$(ghq list | grep ${1} | peco --select-1)"
fi
test -z "${repo_name}" && return 1
pushd "$(ghq root)/${repo_name}"
}
alias cdgh="_cdgh"
## ghg: GitHub Get, clone repo and `pushd` under there.
### arg1: Optional<String> "{owner}/{repo}"
### if undef, select from interactive list.
_ghg() {
if [[ -z ${1} ]]
then
local repos="$(mktemp)"
ghls -L 100 ndxbn > ${repos}
for owner in $(gh org list)
do
ghls -L 100 ${owner} >> ${repos}
done
local repo_name="$(cat ${repos} | peco)"
rm ${repos}
else
local repo_name="${1}"
fi
test -z ${repo_name} && return 1
ghq get -p ${repo_name}
cdgh ${repo_name}
}
alias ghg="_ghg"
## Fork, Clone and `pushd` under there.
### arg1: "{owner}/{repo}"
_ghfork() {
gh repo fork ${1} --clone=false
local fork_repo_name="ndxbn/$(echo ${1} | awk -F/ '{print $2}')"
ghg ${fork_repo_name}
}
alias ghfork="_ghfork"

0 comments on commit c199525

Please sign in to comment.