Skip to content

Commit

Permalink
Enhance command mode tmux session validation
Browse files Browse the repository at this point in the history
fixes #21
  • Loading branch information
ncoop57 committed Dec 30, 2024
1 parent 0443a43 commit 4346fe5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions nbs/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,10 @@
"\n",
" mode = 'default'\n",
" if s: mode = 'sassy'\n",
" if c: mode = 'command'\n",
" if c:\n",
" if os.environ.get('TMUX') is None:\n",
" raise Exception('Must be in a tmux session to use command mode.')\n",
" mode = 'command'\n",
"\n",
" if verbosity>0:\n",
" print(f\"{datetime.now()} | Starting ShellSage request with options {opts}\")\n",
Expand All @@ -897,7 +900,7 @@
" ctxt = '' if skip_system else _sys_info()\n",
"\n",
" # Get tmux history if in a tmux session\n",
" if os.environ.get('TMUX', None):\n",
" if os.environ.get('TMUX'):\n",
" if verbosity>0: print(f\"{datetime.now()} | Adding TMUX history to prompt\")\n",
" if opts.history_lines is None or opts.history_lines < 0:\n",
" opts.history_lines = tmux_history_lim()\n",
Expand Down
7 changes: 5 additions & 2 deletions shell_sage/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ def main(

mode = 'default'
if s: mode = 'sassy'
if c: mode = 'command'
if c:
if os.environ.get('TMUX') is None:
raise Exception('Must be in a tmux session to use command mode.')
mode = 'command'

if verbosity>0:
print(f"{datetime.now()} | Starting ShellSage request with options {opts}")
Expand All @@ -230,7 +233,7 @@ def main(
ctxt = '' if skip_system else _sys_info()

# Get tmux history if in a tmux session
if os.environ.get('TMUX', None):
if os.environ.get('TMUX'):
if verbosity>0: print(f"{datetime.now()} | Adding TMUX history to prompt")
if opts.history_lines is None or opts.history_lines < 0:
opts.history_lines = tmux_history_lim()
Expand Down

0 comments on commit 4346fe5

Please sign in to comment.