mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 22:16:13 +02:00
Check for readline module instead of Windows when initializing autocomplete in install (#1104)
This commit is contained in:
parent
bade28a0b0
commit
48cde1b473
2 changed files with 24 additions and 9 deletions
|
@ -12,14 +12,9 @@ from . import __version__
|
|||
from .config import load_config
|
||||
from .config import verify_config_colors
|
||||
from .exception import UserAbort
|
||||
from .os_compat import on_windows
|
||||
from .prompt import yesno
|
||||
from .upgrade import is_old_version
|
||||
|
||||
if not on_windows:
|
||||
# readline is not included in Windows Active Python
|
||||
import readline
|
||||
|
||||
DEFAULT_CONFIG_NAME = "jrnl.yaml"
|
||||
DEFAULT_JOURNAL_NAME = "journal.txt"
|
||||
DEFAULT_JOURNAL_KEY = "default"
|
||||
|
@ -127,10 +122,7 @@ def load_or_install_jrnl():
|
|||
|
||||
|
||||
def install():
|
||||
if not on_windows:
|
||||
readline.set_completer_delims(" \t\n;")
|
||||
readline.parse_and_bind("tab: complete")
|
||||
readline.set_completer(_autocomplete_path)
|
||||
_initialize_autocomplete()
|
||||
|
||||
# Where to create the journal?
|
||||
path_query = f"Path to your journal file (leave blank for {JOURNAL_FILE_PATH}): "
|
||||
|
@ -159,6 +151,16 @@ def install():
|
|||
return default_config
|
||||
|
||||
|
||||
def _initialize_autocomplete():
|
||||
# readline is not included in Windows Active Python and perhaps some other distributions
|
||||
if sys.modules.get("readline"):
|
||||
import readline
|
||||
|
||||
readline.set_completer_delims(" \t\n;")
|
||||
readline.parse_and_bind("tab: complete")
|
||||
readline.set_completer(_autocomplete_path)
|
||||
|
||||
|
||||
def _autocomplete_path(text, state):
|
||||
expansions = glob.glob(os.path.expanduser(os.path.expandvars(text)) + "*")
|
||||
expansions = [e + "/" if os.path.isdir(e) else e for e in expansions]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue