Merge remote-tracking branch 'upstream/master'

This commit is contained in:
U-Q7X\z 2017-11-02 05:22:58 +08:00
commit 9e0df4361a
20 changed files with 212 additions and 67 deletions

View file

@ -45,7 +45,7 @@ sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/to
### Plugins ### Plugins
Oh My Zsh comes with a shit load of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available.
#### Enabling Plugins #### Enabling Plugins
@ -79,10 +79,11 @@ To use a different theme, simply change the value to match the name of your desi
```shell ```shell
ZSH_THEME="agnoster" # (this is one of the fancy ones) ZSH_THEME="agnoster" # (this is one of the fancy ones)
# you might need to install a special Powerline font on your console's host for this to work
# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster # see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster
``` ```
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._
Open up a new terminal window and your prompt should look something like this: Open up a new terminal window and your prompt should look something like this:
![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png) ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png)
@ -96,6 +97,14 @@ If you're feeling feisty, you can let the computer select one randomly for you e
ZSH_THEME="random" # (...please let it be pie... please be some pie..) ZSH_THEME="random" # (...please let it be pie... please be some pie..)
``` ```
And if you want to pick random theme from a list of your favorite themes:
```shell
ZSH_THEM_RANDOM_CANDIDATES=(
"robbyrussell"
"agnoster"
)
```
## Advanced Topics ## Advanced Topics
@ -217,7 +226,7 @@ We're on the social media.
## Merchandise ## Merchandise
We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](http://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town! We have [stickers](https://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](http://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town!
## License ## License
@ -225,6 +234,6 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt).
## About Planet Argon ## About Planet Argon
![Planet Argon](http://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg) ![Planet Argon](https://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg)
Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github).

View file

@ -93,8 +93,12 @@ done
unset config_file unset config_file
# Load the theme # Load the theme
if [ "$ZSH_THEME" = "random" ]; then if [[ "$ZSH_THEME" == "random" ]]; then
themes=($ZSH/themes/*zsh-theme) if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
else
themes=($ZSH/themes/*zsh-theme)
fi
N=${#themes[@]} N=${#themes[@]}
((N=(RANDOM%N)+1)) ((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]} RANDOM_THEME=${themes[$N]}

View file

@ -5,6 +5,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed
. $HOME/.autojump/share/autojump/autojump.zsh . $HOME/.autojump/share/autojump/autojump.zsh
elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation
. $HOME/.nix-profile/etc/profile.d/autojump.zsh . $HOME/.nix-profile/etc/profile.d/autojump.zsh
elif [ -f /run/current-system/sw/share/autojump/autojump.zsh ]; then # nixos installation
. /run/current-system/sw/share/autojump/autojump.zsh
elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
. /usr/share/autojump/autojump.zsh . /usr/share/autojump/autojump.zsh
elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation

View file

@ -7,10 +7,13 @@ _cargo() {
_arguments \ _arguments \
'(- 1 *)'{-h,--help}'[show help message]' \ '(- 1 *)'{-h,--help}'[show help message]' \
'(- 1 *)'{-V,--version}'[show version information]' \
'(- 1 *)'--list'[list installed commands]' \ '(- 1 *)'--list'[list installed commands]' \
'(- 1 *)'--explain'[Run `rustc --explain CODE`]' \
'(- 1 *)'{-v,--verbose}'[use verbose output]' \ '(- 1 *)'{-v,--verbose}'[use verbose output]' \
'(- 1 *)'--color'[colorization option]' \ '(- 1 *)'--color'[colorization option]' \
'(- 1 *)'{-V,--version}'[show version information]' \ '(- 1 *)'--frozen'[Require Cargo.lock and cache are up to date]' \
'(- 1 *)'--locked'[Require Cargo.lock is up to date]' \
'1: :_cargo_cmds' \ '1: :_cargo_cmds' \
'*:: :->args' '*:: :->args'

View file

@ -35,6 +35,10 @@ alias gflrs='git flow release start'
alias gflff='git flow feature finish' alias gflff='git flow feature finish'
alias gflhf='git flow hotfix finish' alias gflhf='git flow hotfix finish'
alias gflrf='git flow release finish' alias gflrf='git flow release finish'
alias gflfp='git flow feature publish'
alias gflhp='git flow hotfix publish'
alias gflrp='git flow release publish'
alias gflfpll='git flow feature pull'
_git-flow () _git-flow ()
{ {

View file

@ -85,6 +85,7 @@ alias gcs='git commit -S'
alias gd='git diff' alias gd='git diff'
alias gdca='git diff --cached' alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags `git rev-list --tags --max-count=1`' alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
alias gdt='git diff-tree --no-commit-id --name-only -r' alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdw='git diff --word-diff' alias gdw='git diff --word-diff'

View file

@ -7,6 +7,7 @@ _1st_arguments=(
'dashboard:open the dashboard' 'dashboard:open the dashboard'
'reported:search for issues reported by a user' 'reported:search for issues reported by a user'
'assigned:search for issues assigned to a user' 'assigned:search for issues assigned to a user'
'br:open the issue named after the git branch of the current directory'
'dumpconfig:display effective jira configuration' 'dumpconfig:display effective jira configuration'
) )

View file

@ -2,13 +2,19 @@
# #
# See README.md for details # See README.md for details
: ${JIRA_DEFAULT_ACTION:=new}
function jira() { function jira() {
emulate -L zsh emulate -L zsh
local action=${1:=$JIRA_DEFAULT_ACTION} local action jira_url jira_prefix
if [[ -f .jira-default-action ]]; then
action=$(cat .jira-default-action)
elif [[ -f ~/.jira-default-action ]]; then
action=$(cat ~/.jira-default-action)
elif [[ -n "${JIRA_DEFAULT_ACTION}" ]]; then
action=${JIRA_DEFAULT_ACTION}
else
action="new"
fi
local jira_url jira_prefix
if [[ -f .jira-url ]]; then if [[ -f .jira-url ]]; then
jira_url=$(cat .jira-url) jira_url=$(cat .jira-url)
elif [[ -f ~/.jira-url ]]; then elif [[ -f ~/.jira-url ]]; then
@ -51,8 +57,14 @@ function jira() {
echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION" echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION"
else else
# Anything that doesn't match a special action is considered an issue name # Anything that doesn't match a special action is considered an issue name
local issue_arg=$action # but `branch` is a special case that will parse the current git branch
local issue="${jira_prefix}${issue_arg}" if [[ "$action" == "br" ]]; then
local issue_arg=$(git rev-parse --abbrev-ref HEAD)
local issue="${jira_prefix}${issue_arg}"
else
local issue_arg=$action
local issue="${jira_prefix}${issue_arg}"
fi
local url_fragment='' local url_fragment=''
if [[ "$2" == "m" ]]; then if [[ "$2" == "m" ]]; then
url_fragment="#add-comment" url_fragment="#add-comment"

View file

@ -36,6 +36,8 @@ _1st_arguments=(
'loadconfig:Loads and persists the given configuration' 'loadconfig:Loads and persists the given configuration'
'local:List local tasks' 'local:List local tasks'
'local.hex:Install hex locally' 'local.hex:Install hex locally'
'local.phoenix:Updates Phoenix locally'
'local.phx:Updates the Phoenix project generator locally'
'local.rebar:Install rebar locally' 'local.rebar:Install rebar locally'
'new:Create a new Elixir project' 'new:Create a new Elixir project'
'phoenix.digest:Digests and compress static files' 'phoenix.digest:Digests and compress static files'
@ -44,9 +46,24 @@ _1st_arguments=(
'phoenix.gen.json:Generates a controller and model for a JSON based resource' 'phoenix.gen.json:Generates a controller and model for a JSON based resource'
'phoenix.gen.model:Generates an Ecto model' 'phoenix.gen.model:Generates an Ecto model'
'phoenix.gen.secret:Generates a secret' 'phoenix.gen.secret:Generates a secret'
'phoenix.new:Create a new Phoenix application' 'phoenix.new:Creates a new Phoenix v1.2.1 application'
'phoenix.routes:Prints all routes' 'phoenix.routes:Prints all routes'
'phoenix.server:Starts applications and their servers' 'phoenix.server:Starts applications and their servers'
'phx.digest:Digests and compresses static files'
'phx.digest.clean:Removes old versions of static assets.'
'phx.gen.channel:Generates a Phoenix channel'
'phx.gen.context:Generates a context with functions around an Ecto schema'
'phx.gen.embedded:Generates an embedded Ecto schema file'
'phx.gen.html:Generates controller, views, and context for an HTML resource'
'phx.gen.json:Generates controller, views, and context for a JSON resource'
'phx.gen.presence:Generates a Presence tracker'
'phx.gen.schema:Generates an Ecto schema and migration file'
'phx.gen.secret:Generates a secret'
'phx.new:Creates a new Phoenix v1.3.0 application'
'phx.new.ecto:Creates a new Ecto project within an umbrella project'
'phx.new.web:Creates a new Phoenix web project within an umbrella project'
'phx.routes:Prints all routes'
'phx.server:Starts applications and their servers'
'run:Run the given file or expression' 'run:Run the given file or expression'
"test:Run a project's tests" "test:Run a project's tests"
'--help:Describe available tasks' '--help:Describe available tasks'
@ -58,7 +75,7 @@ __task_list ()
local expl local expl
declare -a tasks declare -a tasks
tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server run test) tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server phx.digest phx.digest.clean phx.gen.channel phx.gen.context phx.gen.embedded phx.gen.html phx.gen.json phx.gen.presence phx.gen.schema phx.gen.secret phx.new phx.new.ecto phx.new.web phx.routes phx.server run test)
_wanted tasks expl 'help' compadd $tasks _wanted tasks expl 'help' compadd $tasks
} }

View file

@ -17,6 +17,7 @@ plugins=(... mvn)
| `mvncist` | `mvn clean install -DskipTests` | | `mvncist` | `mvn clean install -DskipTests` |
| `mvncisto` | `mvn clean install -DskipTests --offline` | | `mvncisto` | `mvn clean install -DskipTests --offline` |
| `mvne` | `mvn eclipse:eclipse` | | `mvne` | `mvn eclipse:eclipse` |
| `mvncv` | `mvn clean verify` |
| `mvnd` | `mvn deploy` | | `mvnd` | `mvn deploy` |
| `mvnp` | `mvn package` | | `mvnp` | `mvn package` |
| `mvnc` | `mvn clean` | | `mvnc` | `mvn clean` |

View file

@ -47,6 +47,7 @@ alias mvncist='mvn clean install -DskipTests'
alias mvncisto='mvn clean install -DskipTests --offline' alias mvncisto='mvn clean install -DskipTests --offline'
alias mvne='mvn eclipse:eclipse' alias mvne='mvn eclipse:eclipse'
alias mvnce='mvn clean eclipse:clean eclipse:eclipse' alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
alias mvncv='mvn clean verify'
alias mvnd='mvn deploy' alias mvnd='mvn deploy'
alias mvnp='mvn package' alias mvnp='mvn package'
alias mvnc='mvn clean' alias mvnc='mvn clean'

View file

@ -15,59 +15,93 @@ _rustc_crate_types=(
'lib' 'lib'
'rlib' 'rlib'
'dylib' 'dylib'
'cdylib'
'staticlib' 'staticlib'
'proc-macro'
) )
_rustc_emit_types=( _rustc_emit_types=(
'asm' 'asm'
'bc' 'llvm-bc'
'ir' 'llvm-ir'
'obj' 'obj'
'metadata'
'link' 'link'
'dep-info'
'mir'
)
_rustc_print_types=(
'crate-name'
'file-names'
'sysroot'
'cfg'
'target-list'
'target-cpus'
'target-features'
'relocation-models'
'code-models'
'target-spec-json'
'native-static-libs'
) )
_rustc_pretty_types=( _rustc_pretty_types=(
'normal[un-annotated source]' 'normal[un-annotated source]'
'expanded[crates expanded]' 'expanded[crates expanded]'
'typed[crates expanded, with type annotations]' 'expanded,identified[fully parenthesized, AST nodes with IDs]'
'identified[fully parenthesized, AST nodes and blocks with IDs]' )
_rustc_unpretty_types=(
'normal[un-annotated source]'
'expanded[crates expanded]'
'expanded,identified[fully parenthesized, AST nodes with IDs]'
'flowgraph=[graphviz formatted flowgraph for node]:NODEID:' 'flowgraph=[graphviz formatted flowgraph for node]:NODEID:'
'everybody_loops[all function bodies replaced with `loop {}`]'
'hir[the HIR]'
'hir,identified'
'hir,typed[HIR with types for each node]'
) )
_rustc_color_types=( _rustc_color_types=(
'auto[colorize, if output goes to a tty (default)]' 'auto[colorize, if output goes to a tty (default)]'
'always[always colorize output]' 'always[always colorize output]'
'never[never colorize output]' 'never[never colorize output]'
) )
_rustc_error_format=(
'human'
'json'
)
_rustc_opts_vals=( _rustc_opts_vals=(
--cfg='[Configure the compilation environment]:SPEC:'
-L'[Add a directory to the library search path]:DIR:_files -/'
--crate-name='[Specify the name of the crate being built]' --crate-name='[Specify the name of the crate being built]'
--crate-type='[Comma separated list of types of crates for the compiler to emit]:TYPES:_values -s "," "Crate types" "$_rustc_crate_types[@]"' --crate-type='[Comma separated list of types of crates for the compiler to emit]:TYPES:_values -s "," "Crate types" "$_rustc_crate_types[@]"'
--emit='[Comma separated list of types of output for the compiler to emit]:TYPES:_values -s "," "Emit Targets" "$_rustc_emit_types[@]"' --emit='[Comma separated list of types of output for the compiler to emit]:TYPES:_values -s "," "Emit Targets" "$_rustc_emit_types[@]"'
--print='[Comma separated list of compiler information to print on stdout]:TYPES:_values -s "," "Printable info" "$_rustc_print_types[@]"'
-o'[Write output to <filename>. Ignored if more than one --emit is specified.]:FILENAME:_files'
--out-dir='[Write output to compiler-chosen filename in <dir>. Ignored if -o is specified. (default the current directory)]:DIR:_files -/'
--explain='[Provide a detailed explanation of an error message]:OPT:'
--target='[Target triple cpu-manufacturer-kernel\[-os\] to compile]:TRIPLE:'
--extern'[Specify where an external rust library is located]:ARG:'
--sysroot='[Override the system root]:PATH:_files -/'
--error-format='[How errors and other messages are produced]:TYPES:_values "$_rustc_error_format"'
--debuginfo='[Emit DWARF debug info to the objects created]:LEVEL:_values "Debug Levels" "$_rustc_debuginfo_levels[@]"' --debuginfo='[Emit DWARF debug info to the objects created]:LEVEL:_values "Debug Levels" "$_rustc_debuginfo_levels[@]"'
--dep-info='[Output dependency info to <filename> after compiling]::FILE:_files -/' --dep-info='[Output dependency info to <filename> after compiling]::FILE:_files -/'
--sysroot='[Override the system root]:PATH:_files -/'
--cfg='[Configure the compilation environment]:SPEC:'
--out-dir='[Write output to compiler-chosen filename in <dir>. Ignored if -o is specified. (default the current directory)]:DIR:_files -/'
-o'[Write output to <filename>. Ignored if more than one --emit is specified.]:FILENAME:_files'
--opt-level='[Optimize with possible levels 0-3]:LEVEL:(0 1 2 3)' --opt-level='[Optimize with possible levels 0-3]:LEVEL:(0 1 2 3)'
--pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"' --pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"'
-L'[Add a directory to the library search path]:DIR:_files -/' --unpretty='[Present the input source, unstable (and less-pretty)]::TYPE:_values "TYPES" "$_rustc_unpretty_types[@]"'
--target='[Target triple cpu-manufacturer-kernel\[-os\] to compile]:TRIPLE:'
--color='[Configure coloring of output]:CONF:_values "COLORS" "$_rustc_color_types[@]"' --color='[Configure coloring of output]:CONF:_values "COLORS" "$_rustc_color_types[@]"'
{-v,--version}'[Print version info and exit]::VERBOSE:(verbose)' {-v,--version}'[Print version info and exit]::VERBOSE:(verbose)'
--explain='[Provide a detailed explanation of an error message]:OPT:'
--extern'[Specify where an external rust library is located]:ARG:'
) )
_rustc_opts_switches=( _rustc_opts_switches=(
-g'[Equivalent to --debuginfo=2]' -g'[Equivalent to --debuginfo=2]'
-O'[Equivalent to --opt-level=2]'
--test'[Build a test harness]'
--verbose'[Use verbose output]'
{-h,--help}'[Display this message]' {-h,--help}'[Display this message]'
--no-analysis'[Parse and expand the output, but run no analysis or produce output]' --no-analysis'[Parse and expand the output, but run no analysis or produce output]'
--no-trans'[Run all passes except translation; no output]' --no-trans'[Run all passes except translation; no output]'
-O'[Equivalent to --opt-level=2]'
--parse-only'[Parse only; do not compile, assemble, or link]' --parse-only'[Parse only; do not compile, assemble, or link]'
--print-crate-name'[Output the crate name and exit]' --print-crate-name'[Output the crate name and exit]'
--print-file-name'[Output the file(s) that would be written if compilation continued and exit]' --print-file-name'[Output the file(s) that would be written if compilation continued and exit]'
--test'[Build a test harness]'
) )
_rustc_opts_codegen=( _rustc_opts_codegen=(
'ar=[Path to the archive utility to use when assembling archives.]:BIN:_path_files' 'ar=[Path to the archive utility to use when assembling archives.]:BIN:_path_files'
@ -139,6 +173,9 @@ _rustc_opts_lint=(
_rustc_opts_debug=( _rustc_opts_debug=(
'verbose[in general, enable more debug printouts]' 'verbose[in general, enable more debug printouts]'
'span-free-formats[when debug-printing compiler state, do not include spans]'
"identify-regions[make unnamed regions display as '# (where # is some non-ident unique id)]"
'emit-end-regions[emit EndRegion as part of MIR; enable transforms that solely process EndRegion]'
'time-passes[measure time of each rustc pass]' 'time-passes[measure time of each rustc pass]'
'count-llvm-insns[count where LLVM instrs originate]' 'count-llvm-insns[count where LLVM instrs originate]'
'time-llvm-passes[measure time of each LLVM pass]' 'time-llvm-passes[measure time of each LLVM pass]'

View file

@ -62,6 +62,7 @@ __init() {
'-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \ '-address=[(url) URL of the remote storage server. Required for HTTP backend, optional for Atlas and Consul.]' \
'-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \ '-access-token=[(token) Authentication token for state storage server. Required for Atlas backend, optional for Consul.]' \
'-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \ '-backend=[(atlas) Specifies the type of remote backend. Must be one of Atlas, Consul, or HTTP. Defaults to atlas.]' \
'-backend-config=[(path) Specifies the path to remote backend config file.]' \
'-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \ '-name=[(name) Name of the state file in the state storage server. Required for Atlas backend.]' \
'-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]' '-path=[(path) Path of the remote state in Consul. Required for the Consul backend.]'
} }

View file

@ -3,16 +3,17 @@ wd
[![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd) [![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd)
`wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems ineffecient when the folder is frequently visited or has a long path. `wd` (*warp directory*) lets you jump to custom directories in zsh, without using `cd`. Why? Because `cd` seems inefficient when the folder is frequently visited or has a long path.
*NOTE*: If you are not using zsh, check out the `ruby` branch which has `wd` implemented as a gem. ![tty.gif](https://raw.githubusercontent.com/mfaerevaag/wd/master/tty.gif)
*NEWS*: If you are not using zsh, check out the c-port, [wd-c](https://github.com/mfaerevaag/wd-c), which works with all shells using wrapper functions.
### Setup ### Setup
### oh-my-zsh ### oh-my-zsh
`wd` comes bundles with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)! `wd` comes bundled with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)!
Just add the plugin in your `~/.zshrc` file: Just add the plugin in your `~/.zshrc` file:
@ -27,6 +28,10 @@ Run either in terminal:
* `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh` * `wget --no-check-certificate https://github.com/mfaerevaag/wd/raw/master/install.sh -O - | sh`
##### Arch ([AUR](https://aur.archlinux.org/))
# yaourt -S zsh-plugin-wd-git
#### Manual #### Manual
@ -48,7 +53,7 @@ Run either in terminal:
#### Completion #### Completion
If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utelize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`: If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
fpath=(~/path/to/wd $fpath) fpath=(~/path/to/wd $fpath)
@ -66,7 +71,9 @@ Also, you may have to force a rebuild of `zcompdump` by running:
If a warp point with the same name exists, use `add!` to overwrite it. If a warp point with the same name exists, use `add!` to overwrite it.
Note, a warp point cannot contain colons, or only consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict other features, as below. Note, a warp point cannot contain colons, or only consist of only spaces and dots. The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
You can omit point name to use the current directory's name instead.
* From an other directory (not necessarily), warp to `foo` with: * From an other directory (not necessarily), warp to `foo` with:
@ -84,6 +91,8 @@ Also, you may have to force a rebuild of `zcompdump` by running:
$ wd rm foo $ wd rm foo
You can omit point name to use the current directory's name instead.
* List all warp points (stored in `~/.warprc`): * List all warp points (stored in `~/.warprc`):
$ wd list $ wd list
@ -143,8 +152,8 @@ The project is licensed under the [MIT-license](https://github.com/mfaerevaag/wd
### Finally ### Finally
If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. Explanation on how to run the tests, read the section "Testing" in this README. If you have issues, feedback or improvements, don't hesitate to report it or submit a pull-request. In the case of an issue, we would much appreciate if you would include a failing test in `test/tests.sh`. For an explanation on how to run the tests, read the section "Testing" in this README.
Credit to [altschuler](https://github.com/altschuler) for awesome idea. Credit to [altschuler](https://github.com/altschuler) for an awesome idea.
Hope you enjoy! Hope you enjoy!

View file

@ -16,6 +16,19 @@ function _wd() {
warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" ) warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
typeset -A points
while read -r line
do
arr=(${(s,:,)line})
name=${arr[1]}
path=${arr[2]}
# replace ~ from path to fix completion (#17)
path=${path/#\~/$HOME}
points[$name]=$path
done < $CONFIG
commands=( commands=(
'add:Adds the current working directory to your warp points' 'add:Adds the current working directory to your warp points'
'add!:Overwrites existing warp point' 'add!:Overwrites existing warp point'
@ -34,13 +47,15 @@ function _wd() {
'1: :->first_arg' \ '1: :->first_arg' \
'2: :->second_arg' && ret=0 '2: :->second_arg' && ret=0
local target=$words[2]
case $state in case $state in
first_arg) first_arg)
_describe -t warp_points "Warp points" warp_points && ret=0 _describe -t warp_points "Warp points" warp_points && ret=0
_describe -t commands "Commands" commands && ret=0 _describe -t commands "Commands" commands && ret=0
;; ;;
second_arg) second_arg)
case $words[2] in case $target in
add\!|rm) add\!|rm)
_describe -t points "Warp points" warp_points && ret=0 _describe -t points "Warp points" warp_points && ret=0
;; ;;
@ -56,6 +71,10 @@ function _wd() {
path) path)
_describe -t points "Warp points" warp_points && ret=0 _describe -t points "Warp points" warp_points && ret=0
;; ;;
*)
# complete sub directories from the warp point
_path_files -W "(${points[$target]})" -/ && ret=0
;;
esac esac
;; ;;
esac esac

View file

@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd # @github.com/mfaerevaag/wd
# version # version
readonly WD_VERSION=0.4.2 readonly WD_VERSION=0.4.4
# colors # colors
readonly WD_BLUE="\033[96m" readonly WD_BLUE="\033[96m"
@ -72,25 +72,28 @@ wd_print_msg()
wd_print_usage() wd_print_usage()
{ {
cat <<- EOF cat <<- EOF
Usage: wd [command] <point> Usage: wd [command] [point]
Commands: Commands:
add <point> Adds the current working directory to your warp points add <point> Adds the current working directory to your warp points
add! <point> Overwrites existing warp point add Adds the current working directory to your warp points with current directory's name
rm <point> Removes the given warp point add! <point> Overwrites existing warp point
show Print warp points to current directory add! Overwrites existing warp point with current directory's name
show <point> Print path to given warp point rm <point> Removes the given warp point
list Print all stored warp points rm Removes the given warp point with current directory's name
ls <point> Show files from given warp point show <point> Print path to given warp point
path <point> Show the path to given warp point show Print warp points to current directory
clean! Remove points warping to nonexistent directories list Print all stored warp points
ls <point> Show files from given warp point (ls)
path <point> Show the path to given warp point (pwd)
clean! Remove points warping to nonexistent directories
-v | --version Print version -v | --version Print version
-d | --debug Exit after execution with exit codes (for testing) -d | --debug Exit after execution with exit codes (for testing)
-c | --config Specify config file (default ~/.warprc) -c | --config Specify config file (default ~/.warprc)
-q | --quiet Suppress all output -q | --quiet Suppress all output
help Show this extremely helpful text help Show this extremely helpful text
EOF EOF
} }
@ -131,10 +134,11 @@ wd_getdir()
wd_warp() wd_warp()
{ {
local point=$1 local point=$1
local sub=$2
if [[ $point =~ "^\.+$" ]] if [[ $point =~ "^\.+$" ]]
then then
if [ $#1 < 2 ] if [[ $#1 < 2 ]]
then then
wd_exit_warn "Warping to current directory?" wd_exit_warn "Warping to current directory?"
else else
@ -143,7 +147,12 @@ wd_warp()
fi fi
elif [[ ${points[$point]} != "" ]] elif [[ ${points[$point]} != "" ]]
then then
cd ${points[$point]/#\~/$HOME} if [[ $sub != "" ]]
then
cd ${points[$point]/#\~/$HOME}/$sub
else
cd ${points[$point]/#\~/$HOME}
fi
else else
wd_exit_fail "Unknown warp point '${point}'" wd_exit_fail "Unknown warp point '${point}'"
fi fi
@ -154,6 +163,11 @@ wd_add()
local force=$1 local force=$1
local point=$2 local point=$2
if [[ $point == "" ]]
then
point=$(basename $PWD)
fi
if [[ $point =~ "^[\.]+$" ]] if [[ $point =~ "^[\.]+$" ]]
then then
wd_exit_fail "Warp point cannot be just dots" wd_exit_fail "Warp point cannot be just dots"
@ -163,10 +177,7 @@ wd_add()
elif [[ $point == *:* ]] elif [[ $point == *:* ]]
then then
wd_exit_fail "Warp point cannot contain colons" wd_exit_fail "Warp point cannot contain colons"
elif [[ $point == "" ]] elif [[ ${points[$point]} == "" ]] || $force
then
wd_exit_fail "Warp point cannot be empty"
elif [[ ${points[$2]} == "" ]] || $force
then then
wd_remove $point > /dev/null wd_remove $point > /dev/null
printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
@ -185,6 +196,11 @@ wd_remove()
{ {
local point=$1 local point=$1
if [[ $point == "" ]]
then
point=$(basename $PWD)
fi
if [[ ${points[$point]} != "" ]] if [[ ${points[$point]} != "" ]]
then then
local config_tmp=$WD_CONFIG.tmp local config_tmp=$WD_CONFIG.tmp
@ -294,7 +310,7 @@ wd_clean() {
key=${arr[1]} key=${arr[1]}
val=${arr[2]} val=${arr[2]}
if [ -d "$val" ] if [ -d "${val/#\~/$HOME}" ]
then then
wd_tmp=$wd_tmp"\n"`echo $line` wd_tmp=$wd_tmp"\n"`echo $line`
else else
@ -356,7 +372,8 @@ while read -r line
do do
arr=(${(s,:,)line}) arr=(${(s,:,)line})
key=${arr[1]} key=${arr[1]}
val=${arr[2]} # join the rest, in case the path contains colons
val=${(j,:,)arr[2,-1]}
points[$key]=$val points[$key]=$val
done < $WD_CONFIG done < $WD_CONFIG
@ -424,7 +441,7 @@ else
break break
;; ;;
*) *)
wd_warp $o wd_warp $o $2
break break
;; ;;
--) --)

View file

@ -9,6 +9,13 @@ export ZSH=$HOME/.oh-my-zsh
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="z" ZSH_THEME="z"
# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion. # Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true" # CASE_SENSITIVE="true"

View file

@ -1,4 +1,4 @@
# ZSH Theme - Preview: http://img.skitch.com/20091113-qqtd3j8xinysujg5ugrsbr7x1y.jpg # ZSH Theme - Preview: https://flic.kr/p/ZFvivf
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
PROMPT='%{$fg[green]%}%m%{$reset_color%} %2~ $(git_prompt_info)%{$reset_color%}%B»%b ' PROMPT='%{$fg[green]%}%m%{$reset_color%} %2~ $(git_prompt_info)%{$reset_color%}%B»%b '

View file

@ -107,7 +107,7 @@ main() {
echo '' echo ''
echo 'p.s. Follow us at https://twitter.com/ohmyzsh.' echo 'p.s. Follow us at https://twitter.com/ohmyzsh.'
echo '' echo ''
echo 'p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.' echo 'p.p.s. Get stickers and t-shirts at https://shop.planetargon.com.'
echo '' echo ''
printf "${NORMAL}" printf "${NORMAL}"
env zsh env zsh

View file

@ -33,7 +33,7 @@ then
printf '%s\n' ' /____/ ' printf '%s\n' ' /____/ '
printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version." printf "${BLUE}%s\n" "Hooray! Oh My Zsh has been updated and/or is at the current version."
printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh" printf "${BLUE}${BOLD}%s${NORMAL}\n" "To keep up on the latest news and updates, follow us on twitter: https://twitter.com/ohmyzsh"
printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: http://shop.planetargon.com/" printf "${BLUE}${BOLD}%s${NORMAL}\n" "Get your Oh My Zsh swag at: https://shop.planetargon.com/"
else else
printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?' printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
fi fi