From d69f2850afc189310b40141c839480b42f71775c Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 7 Oct 2016 23:54:54 +0200 Subject: Add non 0 exit code for missing jump targets (#5500) This allows for the user to combine the jump command with something else. In my example cd and jump are now combined like this: ```bash jumpcd() { jump $1 > /dev/null || cd $1 } alias cd="jumpcd" ``` --- plugins/jump/jump.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/jump') diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index e58e7373d..86d9553a2 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -9,7 +9,7 @@ export MARKPATH=$HOME/.marks jump() { - cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" + cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1} } mark() { -- cgit v1.2.3-70-g09d2 From 0853b74fef0fa3a05af7487ff9b15a7f714bb037 Mon Sep 17 00:00:00 2001 From: Ross Lafferty Date: Sat, 1 Sep 2018 07:37:05 -0400 Subject: jump: fix printf path output (#7105) Using the `jump` plugin, using the `marks` command will yield this output: ``` $ marks desktop marks:printf:5: bad option: -> dotfiles marks:printf:5: bad option: -> home marks:printf:5: bad option: -> ``` the `marks` function uses `printf` with `->` and I believe `-` is used by `printf` for left-justification. changing this to `-- "->"` seems to render the appropriate output. ``` desktop -> /Users/uname/Desktop dotfiles -> /Users/uname/.dotfiles home -> /Users/uname ``` --- plugins/jump/jump.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/jump') diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index 86d9553a2..168dfaba2 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -32,7 +32,7 @@ marks() { local markname="$fg[cyan]${link:t}$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color" printf "%s\t" $markname - printf "-> %s \t\n" $markpath + printf -- "-> %s \t\n" $markpath done } -- cgit v1.2.3-70-g09d2 From ca45d510dd5fdd2cc1e92e969c95dbf7e31efb24 Mon Sep 17 00:00:00 2001 From: Rubén Durán Balda Date: Wed, 3 Oct 2018 16:19:46 +0200 Subject: jump: fix behavior when reusing a mark (#7197) Force the mark to point to the new dir, replacing the old one. Fixes #7195 --- plugins/jump/jump.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/jump') diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index 168dfaba2..5a3e7fdf0 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -19,7 +19,7 @@ mark() { MARK="$1" fi if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then - mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK" + mkdir -p "$MARKPATH"; ln -sfh "$PWD" "$MARKPATH/$MARK" fi } -- cgit v1.2.3-70-g09d2 From fe4ac966fab20f9f29c0a9905372b4b52083ef24 Mon Sep 17 00:00:00 2001 From: Jonatan Skogsfors Date: Wed, 3 Oct 2018 17:30:17 +0200 Subject: jump: use more compatible flag for ln (#7205) The flag '-h' isn't universal across implementation. According to FreeBSD man page for ln you can use 'n'. --- plugins/jump/jump.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/jump') diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index 5a3e7fdf0..a19a86022 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -19,7 +19,7 @@ mark() { MARK="$1" fi if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then - mkdir -p "$MARKPATH"; ln -sfh "$PWD" "$MARKPATH/$MARK" + mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK" fi } -- cgit v1.2.3-70-g09d2 From ae548a99733d869f52efa36f146bd020a786a41e Mon Sep 17 00:00:00 2001 From: Rubén Durán Balda Date: Fri, 5 Oct 2018 20:23:30 +0200 Subject: jump: add README (#7237) --- plugins/jump/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 plugins/jump/README.md (limited to 'plugins/jump') diff --git a/plugins/jump/README.md b/plugins/jump/README.md new file mode 100644 index 000000000..ed6415289 --- /dev/null +++ b/plugins/jump/README.md @@ -0,0 +1,19 @@ +# Jump plugin + +This plugin allows to easily jump around the file system by manually adding marks. +Those marks are stored as symbolic links in the directory `$MARKPATH` (default `$HOME/.marks`) + +To use it, add `jump` to the plugins array in your zshrc file: + +```zsh +plugins=(... jump) +``` + +## Commands + +| Command | Description | +|----------------------|-------------------------------------------------------------------------------------------------| +| `jump ` | Jump to the given mark | +| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided | +| `unmark ` | Remove the given mark | +| `marks` | List the existing marks and the directories they point to | -- cgit v1.2.3-70-g09d2 From 3c3766fdf5f64daa4a4e96bee56487314ebcd642 Mon Sep 17 00:00:00 2001 From: Alexander Huynh Date: Mon, 31 Dec 2018 14:15:14 -0500 Subject: Provide even spacing between marks (#7456) Before, when typing the `marks` command, longer mark keys would cause the tabs to spill over to the next tab stop, like so: rc -> /home/ahlex/.rc repos -> /home/ahlex/repos a-longer-string -> /tmp Implement better key display by running through all of the marks twice, once to get the longest key length, and the second time to format everything according to that length: rc -> /home/ahlex/.rc repos -> /home/ahlex/repos a-longer-string -> /tmp --- plugins/jump/jump.plugin.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'plugins/jump') diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh index a19a86022..d161a6da0 100644 --- a/plugins/jump/jump.plugin.zsh +++ b/plugins/jump/jump.plugin.zsh @@ -28,11 +28,18 @@ unmark() { } marks() { + local max=0 + for link in $MARKPATH/*(@); do + if [[ ${#link:t} -gt $max ]]; then + max=${#link:t} + fi + done + local printf_markname_template="$(printf -- "%%%us " "$max")" for link in $MARKPATH/*(@); do local markname="$fg[cyan]${link:t}$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color" - printf "%s\t" $markname - printf -- "-> %s \t\n" $markpath + printf -- "$printf_markname_template" "$markname" + printf -- "-> %s\n" "$markpath" done } -- cgit v1.2.3-70-g09d2