update
This commit is contained in:
parent
e0488cf830
commit
0f5bbd78ad
5 changed files with 46 additions and 7 deletions
3
.vimrc
3
.vimrc
|
@ -12,7 +12,6 @@ if $TERM == 'tmux-256color'
|
||||||
let &t_8b = "\033[48;2;%lu;%lu;%lum"
|
let &t_8b = "\033[48;2;%lu;%lu;%lum"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
set termguicolors
|
|
||||||
set background=dark
|
set background=dark
|
||||||
syntax enable
|
syntax enable
|
||||||
|
|
||||||
|
@ -66,5 +65,7 @@ Plug 'preservim/nerdtree'
|
||||||
Plug 'chiel92/vim-autoformat'
|
Plug 'chiel92/vim-autoformat'
|
||||||
Plug 'natebosch/vim-lsc'
|
Plug 'natebosch/vim-lsc'
|
||||||
Plug 'https://tildegit.org/sloum/gemini-vim-syntax'
|
Plug 'https://tildegit.org/sloum/gemini-vim-syntax'
|
||||||
|
Plug 'meatballs/vim-xonsh'
|
||||||
|
Plug 'davidhalter/jedi-vim'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
5
.xonshrc
5
.xonshrc
|
@ -6,15 +6,12 @@ elif $HOSTNAME == "riley-server":
|
||||||
elif $HOSTNAME == "riley-desktop":
|
elif $HOSTNAME == "riley-desktop":
|
||||||
$PROMPT = '{RED} >< {RESET}| {BOLD_GREEN}{cwd_base}{RESET} ) '
|
$PROMPT = '{RED} >< {RESET}| {BOLD_GREEN}{cwd_base}{RESET} ) '
|
||||||
$XONSH_COLOR_STYLE = 'default'
|
$XONSH_COLOR_STYLE = 'default'
|
||||||
xontrib load argcomplete autovox jedi z bashisms
|
xontrib load argcomplete autovox jedi z bashisms jds
|
||||||
|
|
||||||
source "~/xsh/functions.xsh"
|
source "~/xsh/functions.xsh"
|
||||||
source "~/xsh/exceptions.xsh"
|
source "~/xsh/exceptions.xsh"
|
||||||
source "~/xsh/aliases.xsh"
|
source "~/xsh/aliases.xsh"
|
||||||
|
|
||||||
# TODO: Fix with Arch-based distros
|
|
||||||
# import addins # my extra stuffs :p
|
|
||||||
|
|
||||||
# Windows Subsystem for Linux stuff
|
# Windows Subsystem for Linux stuff
|
||||||
if in_wsl():
|
if in_wsl():
|
||||||
$GPG_TTY=$(tty) # allows gpg to work inside WSL
|
$GPG_TTY=$(tty) # allows gpg to work inside WSL
|
||||||
|
|
41
xontrib/jds.xsh
Normal file
41
xontrib/jds.xsh
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
"""Integrates Johnny Decimal Notation into Xonsh"""
|
||||||
|
|
||||||
|
from xonsh.built_ins import XSH
|
||||||
|
|
||||||
|
HOME = p"/run/media/riley/drive"
|
||||||
|
|
||||||
|
def find_category(number: int, path, regex: str):
|
||||||
|
"""Find matching JDN folder when given notation"""
|
||||||
|
import re
|
||||||
|
folders = path.iterdir()
|
||||||
|
for folder in folders:
|
||||||
|
if not folder.is_dir():
|
||||||
|
continue
|
||||||
|
folder_category = re.match(regex, folder.name)
|
||||||
|
if folder_category is None:
|
||||||
|
continue
|
||||||
|
if len(folder_category.groups()) == 2:
|
||||||
|
if number >= int(folder_category.group(1)) and number <= int(folder_category.group(2)):
|
||||||
|
return folder
|
||||||
|
elif len(folder_category.groups()) == 1:
|
||||||
|
if number == int(folder_category.group((1))):
|
||||||
|
return folder
|
||||||
|
return path
|
||||||
|
|
||||||
|
@XSH.builtins.events.on_transform_command
|
||||||
|
def jds_preproc(cmd: str, **kw):
|
||||||
|
"""processes command strings starting with "`" to cd to matching folder."""
|
||||||
|
if cmd.startswith("`") and "." in cmd:
|
||||||
|
jdn = cmd.replace("`", "")
|
||||||
|
bucket = find_category(int(jdn.split(".")[0]), HOME, r"(^\d0)-(\d9)")
|
||||||
|
category = find_category(int(jdn.split(".")[0]), bucket, r"^(\d\d)")
|
||||||
|
folder = find_category(int(jdn.split(".")[1]), category, r"^(\d\d)")
|
||||||
|
cmd = f"cd '{folder.resolve()}'"
|
||||||
|
elif cmd.startswith("`"):
|
||||||
|
jdn = cmd.replace("`", "")
|
||||||
|
if jdn == "\n":
|
||||||
|
return f"cd '{HOME.resolve()}'"
|
||||||
|
bucket = find_category(int(jdn.split(".")[0]), HOME, r"(^\d0)-(\d9)")
|
||||||
|
category = find_category(int(jdn.split(".")[0]), bucket, r"^(\d\d)")
|
||||||
|
cmd = f"cd '{category.resolve()}'"
|
||||||
|
return cmd
|
|
@ -1,4 +1,4 @@
|
||||||
source xsh/functions.xsh
|
source ~/xsh/functions.xsh
|
||||||
|
|
||||||
def _debug():
|
def _debug():
|
||||||
if $XONSH_SHOW_TRACEBACK:
|
if $XONSH_SHOW_TRACEBACK:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
source xsh/exceptions.xsh
|
source ~/xsh/exceptions.xsh
|
||||||
|
|
||||||
def in_wsl() -> bool:
|
def in_wsl() -> bool:
|
||||||
"""Determines if the system is running inside a WSL environment."""
|
"""Determines if the system is running inside a WSL environment."""
|
||||||
|
|
Loading…
Reference in a new issue