From 76ac48fa92d9192e114876ad1002f533bf71eaa5 Mon Sep 17 00:00:00 2001 From: riley Date: Tue, 19 Oct 2021 23:09:24 -0400 Subject: [PATCH] update doots --- .vimrc | 4 ++-- .xonshrc | 28 +++++++++++++++++++--------- addins/__init__.py | 4 ++-- addins/version.xsh | 46 ++++++++++++++++++++++++++++++---------------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/.vimrc b/.vimrc index 7899cb5..d7ea036 100644 --- a/.vimrc +++ b/.vimrc @@ -39,7 +39,7 @@ set splitright "nnoremap "formatting -set tabstop=4 +set tabstop=2 set softtabstop=0 noexpandtab set shiftwidth=4 @@ -55,7 +55,7 @@ set number nnoremap :NERDTreeToggle "Language server junk -let g:lsc_server_commands = {'py': 'pyls'} +let g:lsc_server_commands = {'py': 'pyls', 'xsh': 'pyls'} let g:lsc_auto_map = v:true diff --git a/.xonshrc b/.xonshrc index c695c13..d3c5f00 100644 --- a/.xonshrc +++ b/.xonshrc @@ -5,12 +5,17 @@ xontrib load apt_tabcomplete argcomplete autovox jedi z # path stuff -$PATH.insert(0, '') -$PATH.extend([ - '~/addins', - '~/.local/bin', - '~/bin', -]) +def load_path(): + import sys + $PATH.extend([ + '~/addins', + '~/.local/bin', + '~/bin', + '~/go/bin' + ]) + sys.path.insert(0, '') + +load_path() import addins # my extra stuffs :p @@ -37,16 +42,20 @@ def _debug(): print("Debug mode enabled.") # bitwarden shit -def _bwc(object : str, id : str): +def _bwc(object : str, bw_id: str): if p'~/.bw_session'.exists(): if $XONSH_SHOW_TRACEBACK: print("loaded .bw_session") source ~/.bw_session else: raise FileNotFoundError("~/.bw_session") - output = $(bw get @(object) @(id)) + output = $(bw get @(object) @(bw_id)) $(echo @(output) | xclip -sel clipboard) - return output + if "password" in object and !(bw get totp @(object[1]) a> /dev/null): + input("totp found, press any key to copy totp ") + output = $(bw get totp @(object[1])) + $(echo @(output) | xclip -sel clipboard) + # return output # aliases aliases.update({ @@ -57,6 +66,7 @@ aliases.update({ 'debug': _debug, 'ls': 'ls -alhs --color=auto', ':q': 'exit', + 'owo': 'echo uwu', }) # man page colors :O diff --git a/addins/__init__.py b/addins/__init__.py index 263a6be..0f45789 100644 --- a/addins/__init__.py +++ b/addins/__init__.py @@ -1,4 +1,4 @@ -from .version import * -from .package import * +from .version import Version +from .package import Package __all__ = ['Version', 'Package'] diff --git a/addins/version.xsh b/addins/version.xsh index b3da493..fba5314 100644 --- a/addins/version.xsh +++ b/addins/version.xsh @@ -1,21 +1,35 @@ +import platform from pathlib import Path __all__ = ['Version'] -class Version: - def __init__(self): - data = self._load_dict() - for key, value in data.items(): - setattr(self, key.lower(), value) - if hasattr(self, "id_like"): # special handling for ID_LIKE - self.id_like = self.id_like.split() +class Platform: + def __init__(self): + self.architecture = platform.architecture() + self.machine = platform.machine() + self.node = platform.node() + self.platform = platform.platform() + self.processor = platform.processor() + self.release = platform.release() + self.system = platform.system() + self.version = platform.version() - def _load_dict(self): - data = {} - os_files = Path('/etc').glob("*-release") - for i in os_files: - with i.open() as f: - for line in f: - line = line.split("=") - data[line[0]] = line[1].strip().replace('"', '') - return data +class Version: + def __init__(self): + data = self._load_dict() + for key, value in data.items(): + setattr(self, key.lower(), value) + if hasattr(self, "id_like"): # special handling for ID_LIKE + self.id_like = self.id_like.split() + if not hasattr(self, "platform"): + self.platform = Platform() + + def _load_dict(self): + data = {} + os_files = Path('/etc').glob("*-release") + for i in os_files: + with i.open() as f: + for line in f: + line = line.split("=") + data[line[0]] = line[1].strip().replace('"', '') + return data