mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 16:53: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
11
dot_config/ipython/profile_default/startup/README
Normal file
11
dot_config/ipython/profile_default/startup/README
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
This is the IPython startup directory
|
||||
|
||||
.py and .ipy files in this directory will be run *prior* to any code or files specified
|
||||
via the exec_lines or exec_files configurables whenever you load this profile.
|
||||
|
||||
Files will be run in lexicographical order, so you can control the execution order of files
|
||||
with a prefix, e.g.::
|
||||
|
||||
00-first.py
|
||||
50-middle.py
|
||||
99-last.ipy
|
||||
69
dot_config/ipython/profile_default/startup/keymap.py
Normal file
69
dot_config/ipython/profile_default/startup/keymap.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
from prompt_toolkit.key_binding import KeyBindings
|
||||
from prompt_toolkit.key_binding.vi_state import InputMode
|
||||
from prompt_toolkit.filters import Condition
|
||||
from IPython import get_ipython
|
||||
|
||||
ip = get_ipython()
|
||||
key_bindings = KeyBindings()
|
||||
|
||||
@Condition
|
||||
def in_navigation_mode():
|
||||
return ip.pt_app.app.vi_state.input_mode == InputMode.NAVIGATION
|
||||
|
||||
# colemak keymap hnei
|
||||
@key_bindings.add("n", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Move cursor down by visual line"
|
||||
event.current_buffer.auto_down(count=event.arg)
|
||||
|
||||
@key_bindings.add("e", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Move cursor up by visual line"
|
||||
event.current_buffer.auto_up(count=event.arg)
|
||||
|
||||
@key_bindings.add("i", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Move cursor right"
|
||||
event.current_buffer.cursor_right(count=event.arg)
|
||||
|
||||
# Insert with 'l' and 'L'
|
||||
@key_bindings.add("l", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Enter insert mode (similar position to 'i' in Colemak)"
|
||||
event.app.vi_state.input_mode = InputMode.INSERT
|
||||
|
||||
@key_bindings.add("L", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Enter insert mode at the beginning of the line"
|
||||
event.current_buffer.cursor_position += event.current_buffer.document.get_start_of_line_position()
|
||||
|
||||
# Ne[k]st
|
||||
@key_bindings.add("k", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Find next match"
|
||||
event.current_buffer.forward_search()
|
||||
|
||||
@key_bindings.add("K", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Find previous match"
|
||||
event.current_buffer.reverse_search()
|
||||
|
||||
# [J]ump
|
||||
@key_bindings.add("j", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Move to end of next word"
|
||||
event.current_buffer.cursor_right_word()
|
||||
|
||||
@key_bindings.add("J", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Move to end of next word with capital E"
|
||||
event.current_buffer.cursor_right_word(end=True)
|
||||
|
||||
# Yank to end of line with 'Y'
|
||||
@key_bindings.add("Y", filter=in_navigation_mode)
|
||||
def _(event):
|
||||
"Yank to the end of the line"
|
||||
text_to_yank = event.current_buffer.document.text_after_cursor
|
||||
event.app.clipboard.set_text(text_to_yank)
|
||||
|
||||
ip.pt_app.key_bindings = key_bindings
|
||||
21
dot_config/ipython/profile_default/startup/magic_ps.py
Normal file
21
dot_config/ipython/profile_default/startup/magic_ps.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from IPython.core.magic import register_line_magic
|
||||
|
||||
@register_line_magic
|
||||
def ps(cmd):
|
||||
output = get_ipython().getoutput(f"pwsh -NoProfile -Command {cmd}")
|
||||
# If no variable is assigned to the output, print it
|
||||
if get_ipython().last_execution_result is None:
|
||||
print("\n".join(output))
|
||||
else:
|
||||
return "\n".join(output)
|
||||
|
||||
|
||||
|
||||
@register_line_magic
|
||||
def nu(cmd):
|
||||
output = get_ipython().getoutput(f"nu -c {cmd}")
|
||||
# If no variable is assigned to the output, print it
|
||||
if get_ipython().last_execution_result is None:
|
||||
print("\n".join(output))
|
||||
else:
|
||||
return "\n".join(output)
|
||||
Loading…
Add table
Add a link
Reference in a new issue