code: def cd_completer(self, event):
      """Completer function for cd, which only returns directories."""
      ip = get_ipython()
      relpath = event.symbol
  
      # print(event) # dbg
      if event.line.endswith("-b") or " -b " in event.line:
          # return only bookmark completions
          bkms = self.db.get("bookmarks", None)
          if bkms:
              return bkms.keys()
          else:
              return []
  
      if event.symbol == "-":
          width_dh = str(len(str(len(ip.user_ns["_dh"]) + 1)))
          # jump in directory history by number
          fmt = "-%0" + width_dh + "d [%s]"
          ents = [fmt % (i, s) for i, s in enumerate(ip.user_ns["_dh"])]
          if len(ents) > 1:
              return ents
          return []
  
      if event.symbol.startswith("--"):
          return ["--" + os.path.basename(d) for d in ip.user_ns["_dh"]]
  
      # Expand ~ in path and normalize directory separators.
      relpath, tilde_expand, tilde_val = expand_user(relpath)
      relpath = relpath.replace("\\", "/")
  
      found = []
      for d in [
          f.replace("\\", "/") + "/"
          for f in glob.glob(relpath + "*")
          if os.path.isdir(f)
      ]:
          if " " in d:
              # we don't want to deal with any of that, complex code
              # for this is elsewhere
              raise TryNext
  
          found.append(d)
  
      if not found:
          if os.path.isdir(relpath):
              return [compress_user(relpath, tilde_expand, tilde_val)]
  
          # if no completions so far, try bookmarks
          bks = self.db.get("bookmarks", {})
          bkmatches = [s for s in bks if s.startswith(event.symbol)]
          if bkmatches:
              return bkmatches
  
          raise TryNext
  
      return [compress_user(p, tilde_expand, tilde_val) for p in found]
  
imports: import glob
  import inspect
  import itertools
  import os
  import re
  import sys
  from importlib import import_module
  from importlib.machinery import all_suffixes
  from time import time
  from zipimport import zipimporter
  from .completer import expand_user, compress_user
  from .error import TryNext
  from ..utils._process_common import arg_split
  from IPython import get_ipython
  from typing import List
  from __res import importer
label_desc: Use image node_id 13 for calling a global function with example usage: cd_completer(event) and returns: unknown, list, unknown, bkms, list, ents, list, bkmatches