summaryrefslogtreecommitdiff
path: root/plugins/jump
diff options
context:
space:
mode:
authorAlexander Huynh <ahrex@users.noreply.github.com>2018-12-31 14:15:14 -0500
committerRobby Russell <robby@planetargon.com>2018-12-31 11:15:14 -0800
commit3c3766fdf5f64daa4a4e96bee56487314ebcd642 (patch)
tree2c08b0a7af3e1c909183239756f6075df2272214 /plugins/jump
parentd0c06d9ec840739623bbc2e1ae0b1f473187d7f2 (diff)
downloadzsh-3c3766fdf5f64daa4a4e96bee56487314ebcd642.tar.gz
zsh-3c3766fdf5f64daa4a4e96bee56487314ebcd642.tar.bz2
zsh-3c3766fdf5f64daa4a4e96bee56487314ebcd642.zip
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
Diffstat (limited to 'plugins/jump')
-rw-r--r--plugins/jump/jump.plugin.zsh11
1 files changed, 9 insertions, 2 deletions
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
}