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]
|
[core]
|
||||||
editor = vim
|
editor = vim
|
||||||
autocrlf = input
|
autocrlf = input
|
||||||
|
pager = less -x1,5
|
||||||
[commit]
|
[commit]
|
||||||
gpgsign = true
|
gpgsign = true
|
||||||
|
|
4
.vimrc
4
.vimrc
|
@ -63,12 +63,8 @@ call plug#begin('~/.vim/plugged')
|
||||||
|
|
||||||
Plug 'airblade/vim-gitgutter'
|
Plug 'airblade/vim-gitgutter'
|
||||||
Plug 'preservim/nerdtree'
|
Plug 'preservim/nerdtree'
|
||||||
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }
|
|
||||||
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 'dracula/vim', { 'as': 'dracula'}
|
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
colorscheme dracula
|
|
||||||
|
|
66
.xonshrc
66
.xonshrc
|
@ -4,7 +4,20 @@ if $HOSTNAME != "riley-laptop":
|
||||||
else:
|
else:
|
||||||
$PROMPT = '{RED} <3 {RESET}| {BOLD_GREEN}{cwd_base}{RESET} ) '
|
$PROMPT = '{RED} <3 {RESET}| {BOLD_GREEN}{cwd_base}{RESET} ) '
|
||||||
$XONSH_COLOR_STYLE = 'default'
|
$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
|
# path stuff
|
||||||
|
|
||||||
|
@ -21,7 +34,8 @@ def load_path():
|
||||||
|
|
||||||
load_path()
|
load_path()
|
||||||
|
|
||||||
import addins # my extra stuffs :p
|
# TODO: Fix with Arch-based distros
|
||||||
|
# import addins # my extra stuffs :p
|
||||||
|
|
||||||
def _colortest():
|
def _colortest():
|
||||||
import sys
|
import sys
|
||||||
|
@ -31,10 +45,14 @@ def _colortest():
|
||||||
sys.stdout.write("\033[0m\n")
|
sys.stdout.write("\033[0m\n")
|
||||||
|
|
||||||
# tmux
|
# tmux
|
||||||
if !(which tmux) and $TERM != 'tmux-256color':
|
try:
|
||||||
|
requires("tmux")
|
||||||
|
if $TERM != 'tmux-256color':
|
||||||
folder = p'.'
|
folder = p'.'
|
||||||
tmux -2 new-session -A -s @(folder.resolve().name)
|
tmux -2 new-session -A -s @(folder.resolve().name)
|
||||||
exit
|
exit
|
||||||
|
except CommandNotFoundException:
|
||||||
|
pass
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
def _debug():
|
def _debug():
|
||||||
|
@ -46,20 +64,36 @@ def _debug():
|
||||||
print("Debug mode enabled.")
|
print("Debug mode enabled.")
|
||||||
|
|
||||||
# bitwarden shit
|
# bitwarden shit
|
||||||
def _bwc(object : str, bw_id: str):
|
def bw_get(object: str, bw_id: str, nulled: bool = False):
|
||||||
if p'~/.bw_session'.exists():
|
if nulled:
|
||||||
if $XONSH_SHOW_TRACEBACK:
|
return !(bw get @(object) @(bw_id) a> /dev/null)
|
||||||
print("loaded .bw_session")
|
return $(bw get @(object) @(bw_id))
|
||||||
source ~/.bw_session
|
|
||||||
else:
|
def _bwc(args: list):
|
||||||
|
requires("bw")
|
||||||
|
if not p'~/.bw_session'.exists():
|
||||||
raise FileNotFoundError("~/.bw_session")
|
raise FileNotFoundError("~/.bw_session")
|
||||||
output = $(bw get @(object) @(bw_id))
|
source ~/.bw_session
|
||||||
$(echo @(output) | xclip -sel clipboard)
|
|
||||||
if "password" in object and !(bw get totp @(object[1]) a> /dev/null):
|
if args[0] == "full": # determine which keys to search for.
|
||||||
input("totp found, press any key to copy totp ")
|
items = ["username", "password", "totp"]
|
||||||
output = $(bw get totp @(object[1]))
|
elif args[0] == "password":
|
||||||
$(echo @(output) | xclip -sel clipboard)
|
items = ["password", "totp"]
|
||||||
# return output
|
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):
|
def _ensure_tmux(args: list):
|
||||||
if $XONSH_SHOW_TRACEBACK:
|
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:
|
That said, here's installation:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
||||||
git clone --bare <git-repo-url> $HOME/.cfg
|
git clone --bare <git-repo-url> $HOME/.cfg
|
||||||
config checkout
|
config checkout
|
||||||
|
config config --local status.showUntrackedFiles no
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue