1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-10-16 11:40:46 +00:00

Compare commits

...

7 commits

Author SHA1 Message Date
Gajanan Gitte
3e494accc5
Merge 66ac7ff0c2 into 99e2c31484 2024-09-18 21:08:56 +02:00
Carlo Sala
99e2c31484
feat(git): add git_previous_branch function
Closes #12538
2024-09-18 21:05:45 +02:00
Francesco Cataldo
e52598a5cc
feat(web-search): add reddit (#12664) 2024-09-18 20:43:52 +02:00
rakeshgm
d91944d47e
feat(gnzh): add virtualenv prompt (#12666) 2024-09-18 20:42:18 +02:00
Tushar Mohod
865291cb7a
feat (terraform): add apply -auto-approve alias (#12658)
Closes #12591
2024-09-18 20:40:54 +02:00
Erik Teichmann
9bcafe1c27
feat(functions): add takezip (#12670) 2024-09-18 20:26:38 +02:00
gajanangitte
66ac7ff0c2 Node plugin completely revamped. Added aliases. 2020-10-22 23:16:22 +05:30
9 changed files with 93 additions and 24 deletions

View file

@ -57,6 +57,16 @@ function takeurl() {
cd "$thedir"
}
function takezip() {
local data thedir
data="$(mktemp)"
curl -L "$1" > "$data"
unzip "$data" -d "./"
thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')"
rm "$data"
cd "$thedir"
}
function takegit() {
git clone "$1"
cd "$(basename ${1%%.git})"
@ -65,6 +75,8 @@ function takegit() {
function take() {
if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
takeurl "$1"
elif [[ $1 =~ ^(https?|ftp).*\.(zip)$ ]]; then
takezip "$1"
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
takegit "$1"
else

View file

@ -162,6 +162,18 @@ function git_current_branch() {
echo ${ref#refs/heads/}
}
# Outputs the name of the previously checked out branch
# Usage example: git pull origin $(git_current_branch)
# rev-parse --symbolic-full-name @{-1} only prints if it is a branch
function git_previous_branch() {
local ref
ref=$(__git_prompt_git rev-parse --quiet --symbolic-full-name @{-1} 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]] || [[ -z $ref ]]; then
return # no git repo or non-branch previous ref
fi
echo ${ref#refs/heads/}
}
# Gets the number of commits ahead from remote
function git_commits_ahead() {

View file

@ -1,15 +1,25 @@
# node plugin
This plugin adds `node-docs` function that opens specific section in [Node.js](https://nodejs.org)
documentation (depending on the installed version).
This plugin provides many a aliases and a few `node-docs` functions.
To use it, add `node` to the plugins array of your zshrc file:
## Aliases
```zsh
plugins=(... node)
```
| Alias | Command |
|:---------------------|:-------------------------------------------------------------------------------|
| nd | node |
| ndc | node --check |
| nde | node --eval "script" |
| ndh | node --help |
| ndi | git --interactive |
| ndr | git --require module |
|----------------------|--------------------------------------------------------------------------------|
| ndnd | node --no-depreciation |
| ndnw | node --no-warnings |
| ndtw | node --trace-warnings |
| ndv8 | node --V8-options |
|----------------------|--------------------------------------------------------------------------------|
## Usage
## Functions
```zsh
# Opens https://nodejs.org/docs/latest-v10.x/api/fs.html
@ -17,3 +27,13 @@ $ node-docs fs
# Opens https://nodejs.org/docs/latest-v10.x/api/path.html
$ node-docs path
```
This plugin adds `node-docs` function that opens specific section in [Node.js](https://nodejs.org)
documentation (depending on the installed version).
## Add plugin
To use it, add `node` to the plugins array of your zshrc file:
```zsh
plugins=(... node)
```

View file

@ -4,3 +4,20 @@ function node-docs {
local section=${1:-all}
open_command "https://nodejs.org/docs/$(node --version)/api/$section.html"
}
# initialise node
alias nd='node'
# Checkout the README.md for
# detailed explanation
alias ndv='node --version'
alias ndc='node -c'
alias nde='node -e'
alias ndh='node -h'
alias ndi='node -i'
alias ndr='node -r'
alias ndnd='node --no-depreciation'
alias ndnw='node --no-warnings'
alias ndtw='node --trace-warnings'
alias ndv8='node --V8-options'

View file

@ -15,22 +15,23 @@ plugins=(... terraform)
## Aliases
| Alias | Command |
|--------|----------------------------|
| `tf` | `terraform` |
| `tfa` | `terraform apply` |
| `tfc` | `terraform console` |
| `tfd` | `terraform destroy` |
| `tff` | `terraform fmt` |
| `tffr` | `terraform fmt -recursive` |
| `tfi` | `terraform init` |
| `tfiu` | `terraform init -upgrade` |
| `tfo` | `terraform output` |
| `tfp` | `terraform plan` |
| `tfv` | `terraform validate` |
| `tfs` | `terraform state` |
| `tft` | `terraform test` |
| `tfsh` | `terraform show` |
| Alias | Command |
|---------|----------------------------------|
| `tf` | `terraform` |
| `tfa` | `terraform apply` |
| `tfaa` | `terraform apply -auto-approve` |
| `tfc` | `terraform console` |
| `tfd` | `terraform destroy` |
| `tff` | `terraform fmt` |
| `tffr` | `terraform fmt -recursive` |
| `tfi` | `terraform init` |
| `tfiu` | `terraform init -upgrade` |
| `tfo` | `terraform output` |
| `tfp` | `terraform plan` |
| `tfv` | `terraform validate` |
| `tfs` | `terraform state` |
| `tft` | `terraform test` |
| `tfsh` | `terraform show` |
## Prompt function

View file

@ -17,6 +17,7 @@ function tf_version_prompt_info() {
alias tf='terraform'
alias tfa='terraform apply'
alias tfaa='terraform apply -auto-approve'
alias tfc='terraform console'
alias tfd='terraform destroy'
alias tff='terraform fmt'

View file

@ -51,6 +51,7 @@ Available search contexts are:
| `packagist` | `https://packagist.org/?query=` |
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
| `chatgpt` | `https://chatgpt.com/?q=` |
| `reddit` | `https://www.reddit.com/search/?q=` |
Also there are aliases for bang-searching DuckDuckGo:

View file

@ -32,6 +32,7 @@ function web_search() {
packagist "https://packagist.org/?query="
gopkg "https://pkg.go.dev/search?m=package&q="
chatgpt "https://chatgpt.com/?q="
reddit "https://www.reddit.com/search/?q="
)
# check whether the search engine is supported
@ -85,6 +86,7 @@ alias npmpkg='web_search npmpkg'
alias packagist='web_search packagist'
alias gopkg='web_search gopkg'
alias chatgpt='web_search chatgpt'
alias reddit='web_search reddit'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'

View file

@ -30,8 +30,9 @@ local return_code="%(?..%F{red}%? ↵%f)"
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
local current_dir="%B%F{blue}%~%f%b"
local git_branch='$(git_prompt_info)'
local venv_prompt='$(virtualenv_prompt_info)'
PROMPT="╭─${user_host} ${current_dir} \$(ruby_prompt_info) ${git_branch}
PROMPT="╭─${venv_prompt}${user_host} ${current_dir} \$(ruby_prompt_info) ${git_branch}
╰─$PR_PROMPT "
RPROMPT="${return_code}"
@ -39,5 +40,7 @@ ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}"
ZSH_THEME_GIT_PROMPT_SUFFIX=" %f"
ZSH_THEME_RUBY_PROMPT_PREFIX="%F{red}"
ZSH_THEME_RUBY_PROMPT_SUFFIX="%f"
ZSH_THEME_VIRTUALENV_PREFIX="%F{red}("
ZSH_THEME_VIRTUALENV_SUFFIX=")%f "
}