Unverified Commit 18ee5dff authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into clipboard

parents d81cd753 368198b7
...@@ -20,10 +20,10 @@ Alias plugin for encoding or decoding using `base64` command ...@@ -20,10 +20,10 @@ Alias plugin for encoding or decoding using `base64` command
) )
``` ```
2. Restart your terminal session or reload configuration by running: 2. Restart your terminal session or restart the shell:
```sh ```sh
source ~/.zshrc exec zsh
``` ```
## Usage and examples ## Usage and examples
......
...@@ -25,23 +25,32 @@ plugins=(... extract) ...@@ -25,23 +25,32 @@ plugins=(... extract)
| `gz` | Gzip file | | `gz` | Gzip file |
| `ipsw` | iOS firmware file | | `ipsw` | iOS firmware file |
| `jar` | Java Archive | | `jar` | Java Archive |
| `lrz` | LRZ archive |
| `lz4` | LZ4 archive |
| `lzma` | LZMA archive | | `lzma` | LZMA archive |
| `rar` | WinRAR archive | | `rar` | WinRAR archive |
| `rpm` | RPM package |
| `sublime-package` | Sublime Text package | | `sublime-package` | Sublime Text package |
| `tar` | Tarball | | `tar` | Tarball |
| `tar.bz2` | Tarball with bzip2 compression | | `tar.bz2` | Tarball with bzip2 compression |
| `tar.gz` | Tarball with gzip compression | | `tar.gz` | Tarball with gzip compression |
| `tar.lrz` | Tarball with lrzip compression |
| `tar.lz` | Tarball with lzip compression |
| `tar.lz4` | Tarball with lz4 compression |
| `tar.xz` | Tarball with lzma2 compression | | `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression | | `tar.zma` | Tarball with lzma compression |
| `tar.zst` | Tarball with zstd compression |
| `tbz` | Tarball with bzip compression | | `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression | | `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression | | `tgz` | Tarball with gzip compression |
| `tlz` | Tarball with lzma compression | | `tlz` | Tarball with lzma compression |
| `txz` | Tarball with lzma2 compression | | `txz` | Tarball with lzma2 compression |
| `tzst` | Tarball with zstd compression |
| `war` | Web Application archive (Java-based) | | `war` | Web Application archive (Java-based) |
| `xpi` | Mozilla XPI module file | | `xpi` | Mozilla XPI module file |
| `xz` | LZMA2 archive | | `xz` | LZMA2 archive |
| `zip` | Zip archive | | `zip` | Zip archive |
| `zst` | Zstandard file (zstd) |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
more information regarding archive formats. more information regarding archive formats.
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
_arguments \ _arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
&& return 0 && return 0
...@@ -40,14 +40,24 @@ extract() { ...@@ -40,14 +40,24 @@ extract() {
tar --lzma --help &> /dev/null \ tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$1" \ && tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;; || lzcat "$1" | tar xvf - ;;
(*.tar.zst|*.tzst)
tar --zstd --help &> /dev/null \
&& tar --zstd -xvf "$1" \
|| zstdcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;; (*.tar) tar xvf "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;;
(*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;;
(*.bz2) bunzip2 "$1" ;; (*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;; (*.xz) unxz "$1" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;;
(*.lz4) lz4 -d "$1" ;;
(*.lzma) unlzma "$1" ;; (*.lzma) unlzma "$1" ;;
(*.z) uncompress "$1" ;; (*.z) uncompress "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;; (*.rar) unrar x -ad "$1" ;;
(*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
(*.7z) 7za x "$1" ;; (*.7z) 7za x "$1" ;;
(*.deb) (*.deb)
mkdir -p "$extract_dir/control" mkdir -p "$extract_dir/control"
...@@ -58,6 +68,7 @@ extract() { ...@@ -58,6 +68,7 @@ extract() {
cd ..; rm *.tar.* debian-binary cd ..; rm *.tar.* debian-binary
cd .. cd ..
;; ;;
(*.zst) unzstd "$1" ;;
(*) (*)
echo "extract: '$1' cannot be extracted" >&2 echo "extract: '$1' cannot be extracted" >&2
success=1 success=1
......
...@@ -4,10 +4,19 @@ ...@@ -4,10 +4,19 @@
local curcontext=$curcontext state line local curcontext=$curcontext state line
declare -A opt_args declare -A opt_args
declare target_list declare -a target_list
target_list=(`fab --shortlist 2>/dev/null`) target_list=("${(@f)$(fab -l 2>/dev/null | awk '{
if (NF == 0 || NR == 1) next
if (NF < 2) print $1
else {
docstring=substr($0, index($0,$2))
gsub(":", "\\:", docstring)
print $1":"docstring
}
}')}")
_targets() { _fab_targets() {
[[ -n "$target_list" ]] || return
_describe -t commands "fabric targets" target_list _describe -t commands "fabric targets" target_list
} }
...@@ -28,7 +37,7 @@ _arguments -w -S -C \ ...@@ -28,7 +37,7 @@ _arguments -w -S -C \
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \ '(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \ '(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
'(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \ '(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
"(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \ "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \
'(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \ '(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \ '(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \ '(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
...@@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then ...@@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
levels) levels)
_describe -t commands "output levels" output_levels;; _describe -t commands "output levels" output_levels;;
*) *)
_targets;; _fab_targets;;
esac esac
return return
......
# fasd
[`Fasd`](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells.
To use it, add `fasd` to the plugins array in your zshrc file:
```zsh
plugins=(... fasd)
```
## Installation
Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install)
## Aliases
| Alias | Command | Description |
|-------|-------------------------------------------|-------------------------------------------------------------|
| v | `fasd -f -e "$EDITOR"` | List frequent/recent files matching the given filename. |
| o | `fasd -a -e xdg-open` | List frequent/recent files and directories matching. |
| j | `fasd_cd -d -i` | cd with interactive selection |
# Fastfile plugin
This plugin adds a way to reference certain files or folders used frequently using
a global alias or shortcut.
To use it, add `fastfile` to the plugins array in your zshrc file:
```zsh
plugins=(... fastfile)
```
## Usage
Example: you access folder `/code/project/backend/database` very frequently.
First, generate a shortcut with the name `pjdb`:
```zsh
$ fastfile pjdb /code/project/backend/database
```
Next time you want to access it, use `§pjdb`. For example:
```zsh
$ cd §pjdb
$ subl §pjdb
```
where § is the fastfile prefix (see [below](#options) for how to change).
**Note:** shortcuts with spaces in the name are assigned a global alias
where the spaces have been substituted with underscores (`_`). For example:
a shortcut named `"hello world"` corresponds with `§hello_world`.
## Functions
- `fastfile <shortcut_name> <path/to/file/or/folder>`: generate a shortcut.
- `fastfile_print <shortcut_name>`: prints a shortcut, with the format
`<prefix><shortcut_name> -> <shortcut_path>`.
- `fastfile_ls`: lists all shortcuts.
- `fastfile_rm <shortcut_name> `: remove a shortcut.
- `fastfile_sync`: generates the global aliases for the shortcuts.
### Internal functions
- `fastfile_resolv <shortcut_name>`: resolves the location of the shortcut
file, i.e., the file in the fastfile directory where the shortcut path
is stored.
- `fastfile_get <shortcut_name>`: get the real path of the shortcut.
## Aliases
| Alias | Function |
|--------|------------------|
| ff | `fastfile` |
| ffp | `fastfile_print` |
| ffrm | `fastfile_rm` |
| ffls | `fastfile_ls` |
| ffsync | `fastfile_sync` |
## Options
These are options you can set to change certain parts of the plugin. To change
them, add `<variable>=<value>` to your zshrc file, before Oh My Zsh is sourced.
For example: `fastfile_var_prefix='@'`.
- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the
created global aliases.
**Default:** `§` (section sign), easy to type in a german keyboard via the combination
[`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg),
or using `⌥ Option`+`6` in macOS.
- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end
with a trailing slash.
**Default:** `$HOME/.fastfile/`.
## Author
- [Karolin Varner](https://github.com/koraa)
################################################################################
# FILE: fastfile.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Michael Varner (musikmichael@web.de)
# VERSION: 1.0.0
#
# This plugin adds the ability to on the fly generate and access file shortcuts.
#
################################################################################
########################### ###########################
# Settings # Settings
# These can be overwritten any time. # These can be overwritten any time.
# If they are not set yet, they will be # If they are not set yet, they will be
...@@ -33,7 +23,7 @@ default fastfile_var_prefix "§" ...@@ -33,7 +23,7 @@ default fastfile_var_prefix "§"
function fastfile() { function fastfile() {
test "$2" || 2="." test "$2" || 2="."
file=$(readlink -f "$2") file=$(readlink -f "$2")
test "$1" || 1="$(basename "$file")" test "$1" || 1="$(basename "$file")"
name=$(echo "$1" | tr " " "_") name=$(echo "$1" | tr " " "_")
...@@ -51,7 +41,7 @@ function fastfile() { ...@@ -51,7 +41,7 @@ function fastfile() {
# Arguments: # Arguments:
# 1. name - The name of the shortcut # 1. name - The name of the shortcut
# STDOUT: # STDOUT:
# The path # The path to the shortcut file
# #
function fastfile_resolv() { function fastfile_resolv() {
echo "${fastfile_dir}${1}" echo "${fastfile_dir}${1}"
...@@ -88,12 +78,12 @@ function fastfile_print() { ...@@ -88,12 +78,12 @@ function fastfile_print() {
# (=> fastfle_print) for each shortcut # (=> fastfle_print) for each shortcut
# #
function fastfile_ls() { function fastfile_ls() {
for f in "${fastfile_dir}"/*; do for f in "${fastfile_dir}"/*; do
file=`basename "$f"` # To enable simpler handeling of spaces in file names file=`basename "$f"` # To enable simpler handeling of spaces in file names
varkey=`echo "$file" | tr " " "_"` varkey=`echo "$file" | tr " " "_"`
# Special format for colums # Special format for colums
echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")" echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
done | column -t -s "|" done | column -t -s "|"
} }
...@@ -102,7 +92,6 @@ function fastfile_ls() { ...@@ -102,7 +92,6 @@ function fastfile_ls() {
# #
# Arguments: # Arguments:
# 1. name - The name of the shortcut (default: name of the file) # 1. name - The name of the shortcut (default: name of the file)
# 2. file - The file or directory to make the shortcut for
# STDOUT: # STDOUT:
# => fastfle_print # => fastfle_print
# #
...@@ -115,11 +104,11 @@ function fastfile_rm() { ...@@ -115,11 +104,11 @@ function fastfile_rm() {
# Generate the aliases for the shortcuts # Generate the aliases for the shortcuts
# #
function fastfile_sync() { function fastfile_sync() {
for f in "${fastfile_dir}"/*; do for f in "${fastfile_dir}"/*; do
file=`basename "$f"` # To enable simpler handeling of spaces in file names file=`basename "$f"` # To enable simpler handeling of spaces in file names
varkey=`echo "$file" | tr " " "_"` varkey=`echo "$file" | tr " " "_"`
alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'" alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
done done
} }
...@@ -133,6 +122,6 @@ alias ffls=fastfile_ls ...@@ -133,6 +122,6 @@ alias ffls=fastfile_ls
alias ffsync=fastfile_sync alias ffsync=fastfile_sync
################################## ##################################
# Init # Init
fastfile_sync fastfile_sync
\ No newline at end of file
# fbterm
This plugin automatically starts [fbterm](https://github.com/zhangyuanwei/fbterm)
if on a real TTY (`/dev/tty*`).
To use it, add fbterm to the plugins array of your zshrc file:
```
plugins=(... fbterm)
```
The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dnf) instead. The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead.
## Flutter plugin
The Flutter plugin provides completion and useful aliases
To use it, add flutter to the plugins array of your zshrc file:
```
plugins=(... flutter)
```
## Aliases
| Alias | Command | Description |
| :--------- | :--------------------- | :------------------------------------------------------------------------- |
| `fl` | `flutter` | Shorthand for flutter command |
| `flr` | `flutter run` | Runs flutter app |
| `fldoc` | `flutter doctor` | Runs flutter doctor |
| `flb` | `flutter build` | Build flutter application |
| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory |
| `flget` | `flutter packages get` | Installs dependencies |
| `flc` | `flutter clean` | Cleans flutter porject |
#compdef flutter
#autoload
local -a _1st_arguments
_1st_arguments=(
"analyze":"Analyze the project's Dart code."
"assemble":"Assemble and build flutter resources."
"attach":"Attach to a running application."
"build":"Flutter build commands."
"channel":"List or switch flutter channels."
"clean":"Delete the build/ and .dart_tool/ directories."
"config":"Configure Flutter settings."
"create":"Create a new Flutter project."
"devices":"List all connected devices."
"doctor":"Show information about the installed tooling."
"drive":"Runs Flutter Driver tests for the current project."
"emulators":"List, launch and create emulators."
"format":" Format one or more dart files."
"help":"Display help information for flutter."
"install":"Install a Flutter app on an attached device."
"logs":"Show log output for running Flutter apps."
"make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers."
"precache":"Populates the Flutter tool's cache of binary artifacts."
"pub":"Commands for managing Flutter packages."
"run":"Run your Flutter app on an attached device."
"screenshot":"Take a screenshot from a connected device."
"test":"Run Flutter unit tests for the current project."
"upgrade":"Upgrade your copy of Flutter."
"version":"List or switch flutter versions."
)
_arguments -C '*:: :->subcmds'
if (( CURRENT == 1 )); then
_describe -t commands "flutter command" _1st_arguments
return
fi
alias fl="flutter"
alias flr="flutter run"
alias fldoc="flutter doctor"
alias flb="flutter build"
alias flattach="flutter attach"
alias flget="flutter packages get"
alias flc="flutter clean"
...@@ -62,6 +62,10 @@ Available search contexts are: ...@@ -62,6 +62,10 @@ Available search contexts are:
If you want to have another context, open an Issue and tell us! If you want to have another context, open an Issue and tell us!
## Fallback search behaviour
The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced.
## Author ## Author
**Wilson Mendes (willmendesneto)** **Wilson Mendes (willmendesneto)**
......
...@@ -27,6 +27,17 @@ alias typescript='frontend typescript' ...@@ -27,6 +27,17 @@ alias typescript='frontend typescript'
alias unheap='frontend unheap' alias unheap='frontend unheap'
alias vuejs='frontend vuejs' alias vuejs='frontend vuejs'
function _frontend_fallback() {
local url
if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then
url="https://duckduckgo.com/?sites=$1&q="
else
url="https://google.com/search?as_sitesearch=$1&as_q="
fi
echo "$url"
}
function frontend() { function frontend() {
emulate -L zsh emulate -L zsh
...@@ -34,8 +45,8 @@ function frontend() { ...@@ -34,8 +45,8 @@ function frontend() {
typeset -A urls typeset -A urls
urls=( urls=(
angular 'https://angular.io/?search=' angular 'https://angular.io/?search='
angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' angularjs $(_frontend_fallback 'angularjs.org')
bem 'https://google.com/search?as_sitesearch=bem.info&as_q=' bem $(_frontend_fallback 'bem.info')
bootsnipp 'https://bootsnipp.com/search?q=' bootsnipp 'https://bootsnipp.com/search?q='
bundlephobia 'https://bundlephobia.com/result?p=' bundlephobia 'https://bundlephobia.com/result?p='
caniuse 'https://caniuse.com/#search=' caniuse 'https://caniuse.com/#search='
...@@ -43,24 +54,24 @@ function frontend() { ...@@ -43,24 +54,24 @@ function frontend() {
compassdoc 'http://compass-style.org/search?q=' compassdoc 'http://compass-style.org/search?q='
cssflow 'http://www.cssflow.com/search?q=' cssflow 'http://www.cssflow.com/search?q='
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
emberjs 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=' emberjs $(_frontend_fallback 'emberjs.com/')
flowtype 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=' flowtype $(_frontend_fallback 'flow.org/en/docs/')
fontello 'http://fontello.com/#search=' fontello 'http://fontello.com/#search='
github 'https://github.com/search?q=' github 'https://github.com/search?q='
html5please 'https://html5please.com/#' html5please 'https://html5please.com/#'
jestjs 'https://www.google.com/search?as_sitesearch=jestjs.io&as_q=' jestjs $(_frontend_fallback 'jestjs.io')
jquery 'https://api.jquery.com/?s=' jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#' lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?q=' mdn 'https://developer.mozilla.org/search?q='
nodejs 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=' nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
npmjs 'https://www.npmjs.com/search?q=' npmjs 'https://www.npmjs.com/search?q='
qunit 'https://api.qunitjs.com/?s=' qunit 'https://api.qunitjs.com/?s='
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=' reactjs $(_frontend_fallback 'reactjs.org/')
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q=' smacss $(_frontend_fallback 'smacss.com')
stackoverflow 'https://stackoverflow.com/search?q=' stackoverflow 'https://stackoverflow.com/search?q='
typescript 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=' typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
unheap 'http://www.unheap.com/?s=' unheap 'http://www.unheap.com/?s='
vuejs 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q=' vuejs $(_frontend_fallback 'vuejs.org')
) )
# show help for command list # show help for command list
......
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}" function setup_using_base_dir() {
# Declare all variables local not no mess with outside env in any way
if [[ -z "${fzf_base}" ]]; then local fzf_base
fzfdirs=( local fzf_shell
"${HOME}/.fzf" local fzfdirs
"/usr/local/opt/fzf" local dir
"/usr/share/fzf"
) test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
for dir in ${fzfdirs}; do
if [[ -d "${dir}" ]]; then if [[ -z "${fzf_base}" ]]; then
fzf_base="${dir}" fzfdirs=(
break "${HOME}/.fzf"
fi "${HOME}/.nix-profile/share/fzf"
done "/usr/local/opt/fzf"
"/usr/share/fzf"
if [[ -z "${fzf_base}" ]]; then "/usr/local/share/examples/fzf"
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then )
if [[ -d "${dir}" ]]; then for dir in ${fzfdirs}; do
fzf_base="${dir}" if [[ -d "${dir}" ]]; then
fi fzf_base="${dir}"
fi break
fi fi
fi done
if [[ -n "${fzf_base}" ]]; then if [[ -z "${fzf_base}" ]]; then
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
# Fix fzf shell directory for Archlinux package if [[ -d "${dir}" ]]; then
if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then fzf_base="${dir}"
fzf_shell="${fzf_base}" fi
else fi
fzf_shell="${fzf_base}/shell" fi
fi fi
# Setup fzf if [[ -d "${fzf_base}" ]]; then
# --------- # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then if [[ ! -d "${fzf_base}/shell" ]]; then
export PATH="$PATH:$fzf_base/bin" fzf_shell="${fzf_base}"
fi else
fzf_shell="${fzf_base}/shell"
# Auto-completion fi
# ---------------
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then # Setup fzf binary path
[[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
fi export PATH="$PATH:$fzf_base/bin"
fi
# Key bindings
# ------------ # Auto-completion
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
source "${fzf_shell}/key-bindings.zsh" [[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
fi fi
else # Key bindings
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\ if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2 source "${fzf_shell}/key-bindings.zsh"
fi fi
else
unset fzf_base fzf_shell dir fzfdirs return 1
fi
}
function setup_using_debian_package() {
(( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
if (( $? )); then
# Either not a debian based distro, or no fzf installed. In any case skip ahead
return 1
fi
# NOTE: There is no need to configure PATH for debian package, all binaries
# are installed to /usr/bin by default
# Determine completion file path: first bullseye/sid, then buster/stretch
local completions="/usr/share/doc/fzf/examples/completion.zsh"
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
# Auto-completion
if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
source $completions 2> /dev/null
fi
# Key bindings
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
source $key_bindings
fi
return 0
}
function indicate_error() {
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
}
# Check for debian package first, because it easy to short cut
# Indicate to user that fzf installation not found if nothing worked
setup_using_debian_package || setup_using_base_dir || indicate_error
unset -f setup_using_debian_package setup_using_base_dir indicate_error
# Gas plugin
This plugin adds autocompletion for the [gas](http://walle.github.com/gas) command,
a utility to manage Git authors.
To use it, add `gas` to the plugins array of your zshrc file:
```zsh
plugins=(... gas)
```
# gcloud
This plugin provides completion support for the
[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/).
To use it, add `gcloud` to the plugins array in your zshrc file.
```zsh
plugins=(... gcloud)
```
It relies on you having installed the SDK using one of the supported options
listed [here](https://cloud.google.com/sdk/install).
## Plugin Options
* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have
your GCloud SDK installed in a non-standard location. The plugin will use this
as the base for your SDK if it finds it set already.
* If you do not have a `python2` in your `PATH` you'll also need to set the
`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is
used by the SDK to call a compatible interpreter when you run one of the
SDK commands.
#####################################################
# gcloud plugin for oh-my-zsh #
# Author: Ian Chesal (github.com/ianchesal) #
#####################################################
if [[ -z "${CLOUDSDK_HOME}" ]]; then
search_locations=(
"$HOME/google-cloud-sdk"
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/usr/share/google-cloud-sdk"
"/snap/google-cloud-sdk/current"
"/usr/lib64/google-cloud-sdk/"
"/opt/google-cloud-sdk"
)
for gcloud_sdk_location in $search_locations; do
if [[ -d "${gcloud_sdk_location}" ]]; then
CLOUDSDK_HOME="${gcloud_sdk_location}"
break
fi
done
fi
if (( ${+CLOUDSDK_HOME} )); then
if (( ! $+commands[gcloud] )); then
# Only source this if GCloud isn't already on the path
if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
source "${CLOUDSDK_HOME}/path.zsh.inc"
fi
fi
source "${CLOUDSDK_HOME}/completion.zsh.inc"
export CLOUDSDK_HOME
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment