mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
chezmoi: bash, ipython, sioyek, zed
This commit is contained in:
parent
295f94ddb9
commit
81da252906
32 changed files with 51 additions and 644 deletions
43
dot_config/ipython/profile_default/ipython_config.py
Normal file
43
dot_config/ipython/profile_default/ipython_config.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
c.TerminalIPythonApp.display_banner = False
|
||||
c.TerminalInteractiveShell.editing_mode = 'vi'
|
||||
c.TerminalInteractiveShell.confirm_exit = False
|
||||
|
||||
# Source: https://ipython.readthedocs.io/en/stable/config/details.html#keyboard-shortcuts
|
||||
def custom_return(shell):
|
||||
|
||||
"""This function is required by the API. It takes a reference to
|
||||
the shell, which is the same thing `get_ipython()` evaluates to.
|
||||
This function must return a function that handles each keypress
|
||||
event. That function, named `handle` here, references `shell`
|
||||
by closure."""
|
||||
|
||||
def handle(event):
|
||||
|
||||
"""This function is called each time `Enter` is pressed,
|
||||
and takes a reference to a Prompt Toolkit event object.
|
||||
If the current input starts with a bang or modulo, then
|
||||
the input is executed, otherwise a newline is entered,
|
||||
followed by any spaces needed to auto-indent."""
|
||||
|
||||
# set up a few handy references to nested items...
|
||||
|
||||
buffer = event.current_buffer
|
||||
document = buffer.document
|
||||
text = document.text
|
||||
|
||||
if text.startswith('!') or text.startswith('%'): # execute the input...
|
||||
|
||||
buffer.accept_action.validate_and_handle(event.cli, buffer)
|
||||
|
||||
else: # insert a newline with auto-indentation...
|
||||
|
||||
if document.line_count > 1: text = text[:document.cursor_position]
|
||||
indent = shell.check_complete(text)[1]
|
||||
buffer.insert_text('\n' + indent)
|
||||
|
||||
# if you just wanted a plain newline without any indentation, you
|
||||
# could use `buffer.insert_text('\n')` instead of the lines above
|
||||
|
||||
return handle
|
||||
|
||||
c.TerminalInteractiveShell.handle_return = custom_return
|
||||
Loading…
Add table
Add a link
Reference in a new issue