bwg improvements
+ added pythonic command existence checking. + split clipboard copying to its own method. + bwg accepts "full" to copy all login fields. - disabled addins for the time being. + improve installation instructions.
This commit is contained in:
parent
94a6e7fddf
commit
dee81351a6
4 changed files with 56 additions and 23 deletions
|
@ -13,5 +13,6 @@
|
|||
[core]
|
||||
editor = vim
|
||||
autocrlf = input
|
||||
pager = less -x1,5
|
||||
[commit]
|
||||
gpgsign = true
|
||||
|
|
4
.vimrc
4
.vimrc
|
@ -63,12 +63,8 @@ call plug#begin('~/.vim/plugged')
|
|||
|
||||
Plug 'airblade/vim-gitgutter'
|
||||
Plug 'preservim/nerdtree'
|
||||
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
|
||||
Plug 'chiel92/vim-autoformat'
|
||||
Plug 'natebosch/vim-lsc'
|
||||
Plug 'https://tildegit.org/sloum/gemini-vim-syntax'
|
||||
Plug 'dracula/vim', { 'as': 'dracula'}
|
||||
|
||||
call plug#end()
|
||||
|
||||
colorscheme dracula
|
||||
|
|
72
.xonshrc
72
.xonshrc
|
@ -4,7 +4,20 @@ if $HOSTNAME != "riley-laptop":
|
|||
else:
|
||||
$PROMPT = '{RED} <3 {RESET}| {BOLD_GREEN}{cwd_base}{RESET} ) '
|
||||
$XONSH_COLOR_STYLE = 'default'
|
||||
xontrib load apt_tabcomplete argcomplete autovox jedi z
|
||||
xontrib load argcomplete autovox jedi z bashisms
|
||||
|
||||
class CommandNotFoundException(Exception):
|
||||
def __init__(self, command):
|
||||
super().__init__(f"Command '{command}' not found.")
|
||||
|
||||
def to_clipboard(text: str):
|
||||
requires("xclip")
|
||||
$(echo -n @(text) | xclip -sel clipboard)
|
||||
|
||||
def requires(command: str):
|
||||
if not !(which @(command)):
|
||||
raise CommandNotFoundException(command)
|
||||
return True
|
||||
|
||||
# path stuff
|
||||
|
||||
|
@ -21,7 +34,8 @@ def load_path():
|
|||
|
||||
load_path()
|
||||
|
||||
import addins # my extra stuffs :p
|
||||
# TODO: Fix with Arch-based distros
|
||||
# import addins # my extra stuffs :p
|
||||
|
||||
def _colortest():
|
||||
import sys
|
||||
|
@ -31,10 +45,14 @@ def _colortest():
|
|||
sys.stdout.write("\033[0m\n")
|
||||
|
||||
# tmux
|
||||
if !(which tmux) and $TERM != 'tmux-256color':
|
||||
folder = p'.'
|
||||
tmux -2 new-session -A -s @(folder.resolve().name)
|
||||
exit
|
||||
try:
|
||||
requires("tmux")
|
||||
if $TERM != 'tmux-256color':
|
||||
folder = p'.'
|
||||
tmux -2 new-session -A -s @(folder.resolve().name)
|
||||
exit
|
||||
except CommandNotFoundException:
|
||||
pass
|
||||
|
||||
# debug
|
||||
def _debug():
|
||||
|
@ -46,20 +64,36 @@ def _debug():
|
|||
print("Debug mode enabled.")
|
||||
|
||||
# bitwarden shit
|
||||
def _bwc(object : str, bw_id: str):
|
||||
if p'~/.bw_session'.exists():
|
||||
if $XONSH_SHOW_TRACEBACK:
|
||||
print("loaded .bw_session")
|
||||
source ~/.bw_session
|
||||
else:
|
||||
def bw_get(object: str, bw_id: str, nulled: bool = False):
|
||||
if nulled:
|
||||
return !(bw get @(object) @(bw_id) a> /dev/null)
|
||||
return $(bw get @(object) @(bw_id))
|
||||
|
||||
def _bwc(args: list):
|
||||
requires("bw")
|
||||
if not p'~/.bw_session'.exists():
|
||||
raise FileNotFoundError("~/.bw_session")
|
||||
output = $(bw get @(object) @(bw_id))
|
||||
$(echo @(output) | xclip -sel clipboard)
|
||||
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
|
||||
source ~/.bw_session
|
||||
|
||||
if args[0] == "full": # determine which keys to search for.
|
||||
items = ["username", "password", "totp"]
|
||||
elif args[0] == "password":
|
||||
items = ["password", "totp"]
|
||||
else:
|
||||
items = [args[0]]
|
||||
|
||||
for i in items: # removes keys that don't exist for the object.
|
||||
if not bw_get(i, args[1], True):
|
||||
items.remove(i)
|
||||
|
||||
print(f"found: {', '.join(items)}")
|
||||
for i in items: # actually copy the info to clipboard.
|
||||
output = bw_get(i, args[1])
|
||||
to_clipboard(output)
|
||||
if items.index(i) < len(items) - 1:
|
||||
input(f"copied {i}, press enter to continue")
|
||||
else:
|
||||
print(f"copied {i}")
|
||||
|
||||
def _ensure_tmux(args: list):
|
||||
if $XONSH_SHOW_TRACEBACK:
|
||||
|
|
|
@ -7,6 +7,8 @@ These dotfiles are... unstable, still being put together, still hashing out how
|
|||
That said, here's installation:
|
||||
|
||||
```sh
|
||||
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
||||
git clone --bare <git-repo-url> $HOME/.cfg
|
||||
config checkout
|
||||
config config --local status.showUntrackedFiles no
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue