Skip to content

Commit

Permalink
Update jump_to_dir.py
Browse files Browse the repository at this point in the history
  • Loading branch information
anki-code committed Feb 22, 2024
1 parent daf17e2 commit a3f1d60
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions xontrib/jump_to_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
_hist_backend = XSH.env.get('XONSH_HISTORY_BACKEND')

if _hist_backend == 'sqlite':
def _jump_to_dir(args, search_column='cwd'):
def _jump_to_dir(args, search_column='cwd', shortcut='j'):
import sqlite3 as _sqlite3
from pathlib import Path as _Path
con = _sqlite3.connect(XSH.env.get('XONSH_HISTORY_FILE'))
Expand All @@ -18,8 +18,8 @@ def _jump_to_dir(args, search_column='cwd'):
WHERE
{search_column} LIKE ?
AND cwd != ?
AND inp NOT LIKE 'j %'
AND inp NOT LIKE 'jc %'
AND inp NOT LIKE '{shortcut} %'
AND inp NOT LIKE '{shortcut}c %'
GROUP BY cwd ORDER BY count(*) DESC
LIMIT 10"""
for row in cur.execute(sql, (f"%{'%'.join(args) if args else ''}%", XSH.env.get('PWD'))):
Expand All @@ -32,9 +32,9 @@ def _jump_to_dir(args, search_column='cwd'):

return 0 if success else 1

c = __xonsh__.env.get('XONTRIB_JUMP_TO_DIR_SHORTCUT', 'j')
aliases[c] = functools.partial(_jump_to_dir, search_column='cwd')
aliases[c+'c'] = functools.partial(_jump_to_dir, search_column='inp')
_sc = __xonsh__.env.get('XONTRIB_JUMP_TO_DIR_SHORTCUT', 'j')
aliases[_sc] = functools.partial(_jump_to_dir, search_column='cwd', shortcut=_sc)
aliases[_sc+'c'] = functools.partial(_jump_to_dir, search_column='inp', shortcut=_sc)

elif __xonsh__.env.get('XONTRIB_JUMP_TO_DIR_WARNING', True):
print(f"xontrib-jump-to-dir: You're using {_hist_backend} for history backend. It's not supported for jump.")
Expand Down

0 comments on commit a3f1d60

Please sign in to comment.