|
140 | 140 | "name": "stdout", |
141 | 141 | "output_type": "stream", |
142 | 142 | "text": [ |
143 | | - "00_core.ipynb\r\n", |
144 | | - "CHANGELOG.md\r\n", |
145 | | - "index.ipynb\r\n", |
| 143 | + "_docs\r\n", |
| 144 | + "_proc\r\n", |
| 145 | + "_quarto.yml\r\n", |
146 | 146 | "\n" |
147 | 147 | ] |
148 | 148 | } |
|
236 | 236 | "name": "stdout", |
237 | 237 | "output_type": "stream", |
238 | 238 | "text": [ |
239 | | - "00_core.ipynb\r\n", |
240 | | - "CHANGELOG.md\r\n", |
241 | | - "index.ipynb\n" |
| 239 | + "_docs\r\n", |
| 240 | + "_proc\r\n", |
| 241 | + "_quarto.yml\n" |
242 | 242 | ] |
243 | 243 | } |
244 | 244 | ], |
|
271 | 271 | "# print(sh('whoami'))" |
272 | 272 | ] |
273 | 273 | }, |
| 274 | + { |
| 275 | + "cell_type": "code", |
| 276 | + "execution_count": null, |
| 277 | + "id": "a64bf8ae", |
| 278 | + "metadata": {}, |
| 279 | + "outputs": [], |
| 280 | + "source": [ |
| 281 | + "#| export\n", |
| 282 | + "@patch\n", |
| 283 | + "def sync_cwd(self:ShellInterpreter):\n", |
| 284 | + " \"Sync session's cwd to match pshnb's cwd\"\n", |
| 285 | + " _cwd = self._ex('pwd').strip()\n", |
| 286 | + " if _cwd != os.getcwd(): os.chdir(_cwd)" |
| 287 | + ] |
| 288 | + }, |
274 | 289 | { |
275 | 290 | "cell_type": "markdown", |
276 | 291 | "id": "af3ce49d", |
|
350 | 365 | " @argument('-X', '--no-expand', action='store_true', help='Disable variable expansion')\n", |
351 | 366 | " @argument('-s', '--sudo', action='store_true', help='Enable sudo')\n", |
352 | 367 | " @argument('-S', '--no-sudo', action='store_true', help='Disable sudo')\n", |
| 368 | + " @argument('-c', '--cwd', action='store_true', help=\"Sync session's cwd to match pshnb's cwd\")\n", |
353 | 369 | " @argument('-t', '--timeout', type=int, help='Set timeout in seconds')\n", |
354 | 370 | " @argument('command', nargs='*', help='The command to run')\n", |
355 | 371 | " @no_var_expand\n", |
|
359 | 375 | " if cell: cell = shell_replace(cell, self.shell)\n", |
360 | 376 | " if line: line = shell_replace(line, self.shell)\n", |
361 | 377 | " args = self.bash.parser.parse_args(line.split())\n", |
| 378 | + " if not self.o: self.reset()\n", |
362 | 379 | " if not args.command and not cell:\n", |
363 | 380 | " if args.expand: return self._xpand(True)\n", |
364 | 381 | " if args.no_expand: return self._xpand(False)\n", |
|
368 | 385 | " if args.reset: return self.reset(args.reset if isinstance(args.reset, str) else None)\n", |
369 | 386 | " if args.help: return self.help()\n", |
370 | 387 | " if args.obj: return self\n", |
| 388 | + " if args.cwd: return self.o.sync_cwd()\n", |
371 | 389 | " if args.command: cell = ' '.join(args.command)\n", |
372 | 390 | " if not cell and line: cell=line\n", |
373 | 391 | " disp = True\n", |
374 | 392 | " if cell.endswith(';'): disp,cell = False,cell[:-1]\n", |
375 | | - " if not self.o: self.reset()\n", |
376 | 393 | " try: res = self.o(cell) or None\n", |
377 | 394 | " except Exception as e:\n", |
378 | 395 | " self.o = None\n", |
|
441 | 458 | "name": "stdout", |
442 | 459 | "output_type": "stream", |
443 | 460 | "text": [ |
444 | | - "00_core.ipynb\tLICENSE\t\tpshnb.egg-info\tsettings.ini\r\n", |
445 | | - "CHANGELOG.md\tMANIFEST.in\tpyproject.toml\tsetup.py\r\n", |
446 | | - "index.ipynb\tpshnb\t\tREADME.md\tstyles.css\n" |
| 461 | + "_docs\t\tCHANGELOG.bak\tLICENSE\t\tpshnb.egg-info\tsetup.py\r\n", |
| 462 | + "_proc\t\tCHANGELOG.md\tMANIFEST.in\tpyproject.toml\tsidebar.yml\r\n", |
| 463 | + "_quarto.yml\tdist\t\tnbdev.yml\tREADME.md\tstyles.css\r\n", |
| 464 | + "00_core.ipynb\tindex.ipynb\tpshnb\t\tsettings.ini\n" |
447 | 465 | ] |
448 | 466 | } |
449 | 467 | ], |
|
542 | 560 | "%bash ls | head -3" |
543 | 561 | ] |
544 | 562 | }, |
| 563 | + { |
| 564 | + "cell_type": "code", |
| 565 | + "execution_count": null, |
| 566 | + "id": "0f71b893", |
| 567 | + "metadata": {}, |
| 568 | + "outputs": [], |
| 569 | + "source": [ |
| 570 | + "%bash -c" |
| 571 | + ] |
| 572 | + }, |
| 573 | + { |
| 574 | + "cell_type": "code", |
| 575 | + "execution_count": null, |
| 576 | + "id": "ad940b0c", |
| 577 | + "metadata": {}, |
| 578 | + "outputs": [ |
| 579 | + { |
| 580 | + "data": { |
| 581 | + "text/plain": [ |
| 582 | + "'/Users/jhoward/aai-ws'" |
| 583 | + ] |
| 584 | + }, |
| 585 | + "execution_count": null, |
| 586 | + "metadata": {}, |
| 587 | + "output_type": "execute_result" |
| 588 | + } |
| 589 | + ], |
| 590 | + "source": [ |
| 591 | + "os.getcwd()" |
| 592 | + ] |
| 593 | + }, |
545 | 594 | { |
546 | 595 | "cell_type": "code", |
547 | 596 | "execution_count": null, |
|
0 commit comments