From 36f8345649be67054d9edec3f09ca05a135c9e97 Mon Sep 17 00:00:00 2001 From: Charles Crete Date: Mon, 31 Oct 2016 23:49:16 -0400 Subject: [PATCH 1/3] wd: Make warp point name optional --- plugins/wd/wd.sh | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh index cf54713bd..1991ced1b 100755 --- a/plugins/wd/wd.sh +++ b/plugins/wd/wd.sh @@ -72,25 +72,28 @@ wd_print_msg() wd_print_usage() { cat <<- EOF -Usage: wd [command] +Usage: wd [command] [point] Commands: - add Adds the current working directory to your warp points - add! Overwrites existing warp point - rm Removes the given warp point - show Print warp points to current directory - show Print path to given warp point - list Print all stored warp points -ls Show files from given warp point -path Show the path to given warp point - clean! Remove points warping to nonexistent directories + add Adds the current working directory to your warp points + add Adds the current working directory to your warp points with current directory's name + add! Overwrites existing warp point + add! Overwrites existing warp point with current directory's name + rm Removes the given warp point + rm Removes the given warp point with current directory's name + show Print path to given warp point + show Print warp points to current directory + list Print all stored warp points + ls Show files from given warp point (ls) + path Show the path to given warp point (pwd) + clean! Remove points warping to nonexistent directories - -v | --version Print version - -d | --debug Exit after execution with exit codes (for testing) - -c | --config Specify config file (default ~/.warprc) - -q | --quiet Suppress all output + -v | --version Print version + -d | --debug Exit after execution with exit codes (for testing) + -c | --config Specify config file (default ~/.warprc) + -q | --quiet Suppress all output - help Show this extremely helpful text + help Show this extremely helpful text EOF } @@ -154,6 +157,11 @@ wd_add() local force=$1 local point=$2 + if [[ $point == "" ]] + then + point=$(basename $(pwd)) + fi + if [[ $point =~ "^[\.]+$" ]] then wd_exit_fail "Warp point cannot be just dots" @@ -163,9 +171,6 @@ wd_add() elif [[ $point == *:* ]] then wd_exit_fail "Warp point cannot contain colons" - elif [[ $point == "" ]] - then - wd_exit_fail "Warp point cannot be empty" elif [[ ${points[$2]} == "" ]] || $force then wd_remove $point > /dev/null @@ -183,7 +188,12 @@ wd_add() wd_remove() { - local point=$1 + local point=$2 + + if [[ $point == "" ]] + then + point=$(basename $(pwd)) + fi if [[ ${points[$point]} != "" ]] then From fe723da55349695f0afc6907383b9507a6e4c77a Mon Sep 17 00:00:00 2001 From: Charles Crete Date: Mon, 31 Oct 2016 23:54:51 -0400 Subject: [PATCH 2/3] wd: Update README --- plugins/wd/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/wd/README.md b/plugins/wd/README.md index ed149eb3e..2d7b46bbd 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -68,6 +68,8 @@ Also, you may have to force a rebuild of `zcompdump` by running: 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. + You can omit point name to use the current directory's name instead. + * From an other directory (not necessarily), warp to `foo` with: $ wd foo @@ -84,6 +86,8 @@ Also, you may have to force a rebuild of `zcompdump` by running: $ wd rm foo + You can omit point name to use the current directory's name instead. + * List all warp points (stored in `~/.warprc`): $ wd list From 23f31f39f201af54fc5075d2206f2b2060d26ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 2 Nov 2016 11:09:35 +0100 Subject: [PATCH 3/3] wd: minor README fixes --- plugins/wd/README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/wd/README.md b/plugins/wd/README.md index 2d7b46bbd..935dadd1b 100644 --- a/plugins/wd/README.md +++ b/plugins/wd/README.md @@ -1,5 +1,4 @@ -wd -== +# wd plugin [![Build Status](https://travis-ci.org/mfaerevaag/wd.png?branch=master)](https://travis-ci.org/mfaerevaag/wd) @@ -68,7 +67,7 @@ Also, you may have to force a rebuild of `zcompdump` by running: 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. - You can omit point name to use the current directory's name instead. + You can omit the point name to use the current directory's name instead. * From an other directory (not necessarily), warp to `foo` with: @@ -80,13 +79,13 @@ Also, you may have to force a rebuild of `zcompdump` by running: $ wd ... This is a wrapper for the zsh `dirs` function. - (You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)). + (You might need `setopt AUTO_PUSHD` in your `.zshrc` if you are not using [Oh My Zsh](https://github.com/robbyrussell/oh-my-zsh)). * Remove warp point test point: $ wd rm foo - You can omit point name to use the current directory's name instead. + You can omit the point name to use the current directory's name instead. * List all warp points (stored in `~/.warprc`):