replace vim_askpass_helper by python.tkinter realisation
This commit is contained in:
parent
cb31836972
commit
6126294686
@ -77,7 +77,7 @@ map("c", '%%', [[getcmdtype() == ':' ? expand('%:h').'/' : '%%']], {expr = true}
|
|||||||
|
|
||||||
|
|
||||||
-- Save from root
|
-- Save from root
|
||||||
vim.api.nvim_create_user_command('W', [[execute 'silent! write !SUDO_ASKPASS=vim_askpass_helper_python sudo -A tee % >/dev/null' <bar> edit!]], {})
|
vim.api.nvim_create_user_command('W', [[execute 'silent! write !SUDO_ASKPASS=vim_askpass_helper sudo -A tee % >/dev/null' <bar> edit!]], {})
|
||||||
vim.cmd([[autocmd FileChangedRO * set readonly!]])
|
vim.cmd([[autocmd FileChangedRO * set readonly!]])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,44 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env python3
|
||||||
echo -e "SETTITLE vim\nOPTION default-prompt=[sudo] password for $USER:\nGETPIN" | pinentry --display :0 2>/dev/null | grep ^D | cut -d" " -f2-
|
|
||||||
|
import os
|
||||||
|
import tkinter as tk
|
||||||
|
from tkinter import Entry, Label
|
||||||
|
|
||||||
|
|
||||||
|
class App:
|
||||||
|
def __init__(self):
|
||||||
|
self.root = tk.Tk()
|
||||||
|
self.root.title("vim")
|
||||||
|
self.root.attributes('-type', 'dialog')
|
||||||
|
|
||||||
|
self.create_label()
|
||||||
|
self.create_widget_get_password()
|
||||||
|
self.create_button_ok()
|
||||||
|
|
||||||
|
def mainloop(self):
|
||||||
|
self.root.mainloop()
|
||||||
|
|
||||||
|
def __event_get(self, _):
|
||||||
|
print(self.widget.get())
|
||||||
|
self.root.quit()
|
||||||
|
|
||||||
|
def create_label(self):
|
||||||
|
label_text = f"[sudo] password for {os.getlogin()}:"
|
||||||
|
user_password = Label(self.root, text = label_text)
|
||||||
|
user_password.grid(row = 1, column = 1)
|
||||||
|
|
||||||
|
def create_widget_get_password(self):
|
||||||
|
self.widget = Entry(self.root, show="*", width=15)
|
||||||
|
self.widget.grid(row = 1, column = 2)
|
||||||
|
self.widget.focus_set()
|
||||||
|
|
||||||
|
def create_button_ok(self):
|
||||||
|
btn = tk.Button(self.root, text="OK")
|
||||||
|
btn.bind("<Button-1>", self.__event_get)
|
||||||
|
self.root.bind("<Return>", self.__event_get)
|
||||||
|
btn.grid(row = 1, column = 3)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = App()
|
||||||
|
app.mainloop()
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import os
|
|
||||||
import tkinter as tk
|
|
||||||
from tkinter import Entry, Label
|
|
||||||
|
|
||||||
|
|
||||||
class App:
|
|
||||||
def __init__(self):
|
|
||||||
self.root = tk.Tk()
|
|
||||||
self.root.title("vim")
|
|
||||||
self.root.attributes('-type', 'dialog')
|
|
||||||
|
|
||||||
self.create_label()
|
|
||||||
self.create_widget_get_password()
|
|
||||||
self.create_button_ok()
|
|
||||||
|
|
||||||
def mainloop(self):
|
|
||||||
self.root.mainloop()
|
|
||||||
|
|
||||||
def __event_get(self, _):
|
|
||||||
print(self.widget.get())
|
|
||||||
self.root.quit()
|
|
||||||
|
|
||||||
def create_label(self):
|
|
||||||
label_text = f"[sudo] password for {os.getlogin()}:"
|
|
||||||
user_password = Label(self.root, text = label_text)
|
|
||||||
user_password.grid(row = 1, column = 1)
|
|
||||||
|
|
||||||
def create_widget_get_password(self):
|
|
||||||
self.widget = Entry(self.root, show="*", width=15)
|
|
||||||
self.widget.grid(row = 1, column = 2)
|
|
||||||
self.widget.focus_set()
|
|
||||||
|
|
||||||
def create_button_ok(self):
|
|
||||||
btn = tk.Button(self.root, text="OK")
|
|
||||||
btn.bind("<Button-1>", self.__event_get)
|
|
||||||
self.root.bind("<Return>", self.__event_get)
|
|
||||||
btn.grid(row = 1, column = 3)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app = App()
|
|
||||||
app.mainloop()
|
|
||||||
4
install
4
install
@ -15,7 +15,7 @@ declare -r -A TARGETS=(
|
|||||||
["zsh"]="%bash .config/zsh .zshenv .inputrc"
|
["zsh"]="%bash .config/zsh .zshenv .inputrc"
|
||||||
["tmux"]=".tmux.conf"
|
["tmux"]=".tmux.conf"
|
||||||
["alacritty"]=".config/alacritty"
|
["alacritty"]=".config/alacritty"
|
||||||
["nvim"]=".config/nvim .editorconfig .local/bin/vim_askpass_helper .local/bin/vim_askpass_helper_python"
|
["nvim"]=".config/nvim .editorconfig .local/bin/vim_askpass_helper"
|
||||||
["ssh"]=""
|
["ssh"]=""
|
||||||
["less"]=".lesskey"
|
["less"]=".lesskey"
|
||||||
["git"]=".config/git"
|
["git"]=".config/git"
|
||||||
@ -208,4 +208,4 @@ case "$executed_command" in
|
|||||||
help) shift; cmd_help "$@" ;;
|
help) shift; cmd_help "$@" ;;
|
||||||
*) shift; cmd_install "$executed_command" "$@" ;;
|
*) shift; cmd_install "$executed_command" "$@" ;;
|
||||||
esac
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
Loading…
x
Reference in New Issue
Block a user