Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A autojump
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 158
    • Issues 158
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 54
    • Merge requests 54
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • William Ting
  • autojump
  • Issues
  • #490
Closed
Open
Issue created Jul 16, 2017 by Administrator@rootContributor

Cleaner zsh completion

Created by: jamesk

Hi, love autojump, I've just started using it with zsh (and oh-my-zsh) and I had what seemed like a bug in the completion, duplicate folder entries. The completion also automatically added __ to my command as all results from autojump -complete start with the search term and __.

Anyway, posting this in case it affects anyone else / you want to incorporate it into autojump. This is my modified _j file:

#compdef j
cur=${words[2, -1]}

integer i=1
declare -A displayMap

autojump --complete "${=cur[*]}" | while read c; do
    hidden=$(echo "$c" | sed 's/\(.*__[0-9][0-9]*__\).*/\1/')
    display=$(echo "$c" | sed 's/.*__[0-9][0-9]*__\(.*\)/\1/')

    (( $+displayMap[$display] )) && continue
    displayMap[$display]=true

    compadd -V $i -U -i "$hidden" "$display";
    i=$((i+1))
done

(( $i > 2 )) && compadd -V $i -U "${=cur[*]}"

Modifications:

  • It doesn't display the XXX__N__ prefix
  • Maintains order via -V arg to compadd
  • If there is more than one result: adds a final auto completion entry equal to the user's current argument, this stops the completion from modifying the command until the user actually selects one of the options.
Assignee
Assign to
Time tracking