Package: xontrib-skim
skim(fuzzy finder) integration intoxonsh(shell)Sets up keybinds to search various type of data: dirs/files, history of commands/CWDs/dirs, ssh hosts...InstallationTo install use pip:xpip install xontrib-skim
# or: xpip install -U git+https://github.com/eugenesvk/xontrib-skimUsageSupported data sources:xonsh history of commands (and their frequency)xonsh history of commands' CWDs (and the frequency of commands started here)zoxide's history of dirs(CWDs and dirs) support multi-selection (with proper escape-quoting) as well ascd-ing to the selected dirfiles in the current directory and its sub-directoriesdirs in the current directory and its sub-directoriesssh hosts from/etc/ssh/ssh_config,~/.ssh/config,~/.ssh/known_hostsThis xontrib requiressk(orsk-tmux) to be inPATH. If it's added toPATHvia another xontrib (e.g, you installed it via Homebrew and usexontrib-homebrew), then you should load this xontrib after the one settingPATHAdd the following to your.pyxontrib loading config andimportit in your xonsh run control file (~/.xonshrcor~/.config/rc.xsh):fromxonsh.xontribsimportxontribs_loadfromxonsh.built_insimportXSHenvx=XSH.envxontribs=["skim",# Initializes skim (polyglot asdf-like runtime manager)# your other xontribs]# ↓ optional configuration variables (use `False` to disable a keybind)if'skim'inxontribs:# Configure skim only if you're actually loading it# config var                	  value	 |default|alt_cmd¦ commentenvx["X_SKIM_KEY_HIST"]="⎈s"#|c-s|             False¦ Search in history entries and insert the chosen commandenvx["X_SKIM_KEY_HIST_CWD→"]="⎇s"#|['escape','s']|  False¦ Search in history entries' CWD and CD to the selected item (if exists, do nothing otherwise)envx["X_SKIM_KEY_HIST_CWD"]="⎈⎇s"#|['escape','c-s']|False¦ Search in history entries' CWD and insert the selected item(s)envx["X_SKIM_KEY_HIST_Z→"]="⎇z"#|['escape','z']|  False¦ Search in zoxide's history entries and CD to the selected item (if exists, do nothing otherwise)envx["X_SKIM_KEY_HIST_Z"]="⎈⎇z"#|['escape','c-z']|False¦ Search in zoxide's history entries and insert the selected item(s)envx["X_SKIM_KEY_FILE"]="⎈f"#|c-f|             False¦ Find files in the current directory and its sub-directoriesenvx["X_SKIM_KEY_DIR"]="⎇f"#|['escape','f']|  False¦ Find dirs  in the current directory and its sub-directoriesenvx["X_SKIM_KEY_SSH"]="⎈b"#|c-b|             False¦ Run 'ssh HOST' for hosts in /etc/ssh/ssh_config, ~/.ssh/config, ~/.ssh/known_hosts# run to see the allowed list for ↑: from prompt_toolkit.keys import ALL_KEYS; print(ALL_KEYS)# Alt is also supported as either of: a- ⎇ ⌥ (converted to a prefix 'escape')# Control symbols are also supported as either of: ⎈ ⌃# ↓ are key bindings for the skim binary itself, not this xontrib, so use skim rules https://github.com/lotabout/skim#keymapenvx["X_SKIM_KEY_SORT_TOGGLE"]="ctrl-r"#|ctrl-r|False¦ ⎈R binding for 'toggle-sort'envx["X_SKIM_KEY_CUSTOM"]=None#|None| a dictionary of {'key':'action'}envx["X_SKIM_NO_HEIGHT"]=True#|True|False¦ disable `--height` to fix a skim bugenvx["X_SKIM_NO_SORT"]=True#|True|False¦ disable history sortingenvx["X_SKIM_CMD_FRQ"]=True#|True|False¦ add ∑command runs for a given commandenvx["X_SKIM_CMD_FRQ_MIN"]=5#|5| hide frequency numbers below thisenvx["X_SKIM_CWD_FRQ"]=True#|True|False¦ add ∑command runs at a given CWDenvx["X_SKIM_CWD_FRQ_MIN"]=5#|5| hide frequency numbers below thisenvx["X_SKIM_CMD_FIND"]="fd -t f -t l"#|None| command used by skim to search for filesenvx["X_SKIM_CMD_FIND_DIR"]="fd -t d     "#|None| command used by skim to search for directoriesenvx["X_SKIM_DIR_VIEW"]="ls -F --color=always {2..}"#|None| preview function for Dir listsenvx["SKIM_DEFAULT_OPTIONS"]="--ansi --preview-window=right:40%:wrap"# |None| other options to pass to skimxontribs_load(xontribs)# actually load all xontribs in the listOr just add this to your xonsh run control filexontrib load skim # Initializes skim (fuzzy finder)
# configure like in the example above, but replace envx['VAR'] with $VAR
$X_SKIM_KEY_HISTORY	= "c-s" # ...Examplescdto a path in-place without losing the command you've already typed in the prompt!Press⎇s(for command history CWD's) or⎇z(for zoxide's history) to launch fuzzy finder of your favorite dirsFind the correct dir and insert itThe prompt is updated in the background, reflecting the dir change and preserving the commandFind fils/dirs in xonsh-completed paths: typecd ~/Mus; hit⎈Fto limit your file search to~/MusicFind files with⎈Fand dirs with⎇Fenvx["X_SKIM_KEY_FILE"]="⎇f"envx["X_SKIM_KEY_DIR"]="⎈f"Insert multiple paths with home row cursor keys⎇Jto toggle and ▼⎇Kto toggle and ▲envx["X_SKIM_KEY_CUSTOM"]={'alt-j':'toggle+down','alt-k':'toggle+up'}Known issuesskim doesn't clear the screen properly when--heightis set due to abug. At the moment this flag is disabled viaX_SKIM_NO_HEIGHTskim sometimes prints extraneous text symbols, e.g., when searching history, maybe due tothis bugor something elseskim might bug in tmux on some system/terminalsbug1,bug2toggle-sort(andX_SKIM_KEY_SORT_TOGGLE) doesn't seem to be supported in skim,ls | sk --bind=pgdn:toggle-sortalso failsto remove extra?[38;5;26mFOLDERfrom output, add--ansito$SKIM_DEFAULT_OPTIONSor disable colors in your$X_SKIM_CMD_FIND/DIRfilter (e.g.,fd -t d -c never)⎈/⎇fconflict withxontrib-output-search's defaultsCreditsThis package was created withxontrib template