Remove xonsh

This commit is contained in:
Kujiu 2024-02-10 20:58:27 +01:00
parent d851c3f9f7
commit 920a72556e
Signed by: kujiu
GPG key ID: ABBB2CAC6855599F
8 changed files with 3 additions and 440 deletions

View file

@ -12,7 +12,7 @@ Some configurations for these tools:
- Passwords in Bitwarden (access by keyring or bw-cli)
- Neomutt + notmuch + afew (mail)
- vdirsyncer + khal + khard (calendar and contacts)
- fish & xonsh
- fish
- poezio (XMPP)
- newsboat (RSS with FreshRSS)
- toot (Mastodon client)

View file

@ -221,16 +221,6 @@ function update-homes -d "Update homes configuration"
echo
pip install "git+https://procrastinator.nerv-project.eu/kujiu/pygments_nightfox_style" --user --break-system-packages
echo
echo
echo (set_color 719cd6)"*** Install xonsh plugins ***"(set_color normal)
echo
echo "xpip install -U xontrib-commands xontrib-gitinfo \
xontrib-broot xontrib-hist-navigator xontrib-prompt-vi-mode \
xontrib-vox xontrib-abbrevs xontrib-argcomplete xontrib-django \
xonsh-docker-tabcomplete xontrib-fish-completer xontrib-jedi\
xontrib-makefile-complete --break-system-packages; exit(1)" | xonsh
echo
echo
echo (set_color 719cd6)"*** Install hgrep ***"(set_color normal)

View file

@ -1,299 +0,0 @@
#!/usr/bin/env xonsh
from prompt_toolkit.key_binding.vi_state import InputMode
$SHELL_TYPE = "prompt_toolkit"
$PROMPT_TOOLKIT_COLOR_DEPTH = "DEPTH_24_BIT"
$NFOX_BLACK = "#393b44"
$NFOX_RED = "#c94f6d"
$NFOX_GREEN = "#81b29a"
$NFOX_YELLOW = "#dbc074"
$NFOX_BLUE = "#719cd6"
$NFOX_MAGENTA = "#9d79d6"
$NFOX_CYAN = "#63cdcf"
$NFOX_WHITE = "#dfdfe0"
$NFOX_ORANGE = "#f4a261"
$NFOX_PINK = "#d67ad2"
$NFOX_COMMENT = "#738091"
$NFOX_BG0 = "#131a24"
$NFOX_BG1 = "#192330"
$NFOX_BG2 = "#212e3f"
$NFOX_BG3 = "#29394f"
$NFOX_BG4 = "#39506d"
$NFOX_FG0 = "#d6d6d7"
$NFOX_FG1 = "#cdcecf"
$NFOX_FG2 = "#aeafb0"
$NFOX_FG3 = "#71839b"
$NFOX_SEL0 = "#2b3b51"
$NFOX_SEL1 = "#3c5372"
# Darker
$NFOX_BLACK_D = "#13151e"
$NFOX_RED_D = "#a32947"
$NFOX_GREEN_D = "#5b8c74"
$NFOX_YELLOW_D = "#b59a4e"
$NFOX_BLUE_D = "#4b76b0"
$NFOX_MAGENTA_D = "#7753b0"
$NFOX_CYAN_D = "#3da7a9"
$NFOX_WHITE_D = "#b9b9ba"
$NFOX_ORANGE_D = "#ce7c3b"
$NFOX_PINK_D = "#b054ac"
#Lighter
$NFOX_BLACK_L = "#5F616A"
$NFOX_RED_L = "#ef7593"
$NFOX_GREEN_L = "#9bccb4"
$NFOX_YELLOW_L = "#ffe69a"
$NFOX_BLUE_L = "#97c2fc"
$NFOX_MAGENTA_L = "#eac6ff"
$NFOX_CYAN_L = "#89f3f5"
$NFOX_WHITE_L = "#ffffff"
$NFOX_ORANGE_L = "#ffc887"
$NFOX_PINK_L = "#fca0f8"
# Load all plugins
xontrib load commands
xontrib load gitinfo
xontrib load broot
xontrib load hist_navigator
xontrib load vox
xontrib load autovox
xontrib load voxapi
xontrib load abbrevs
xontrib load argcomplete
xontrib load django
xontrib load docker_tabcomplete
xontrib load fish_completer
xontrib load jedi
xontrib load makefile_complete
$VI_MODE = True
$XONSH_SHOW_TRACEBACK = True
$COMPLETIONS_CONFIRM=True
$DOCKER_BASE_URL = "unix://var/run/docker.sock"
$VISUAL = "nvim"
$EDITOR = "lvim"
$PAGER = "nvimpager"
$BROWSER = "elinks"
$PATH = [
p"~/.local/bin",
p"~/.cargo/bin",
p"~/go/bin",
p"/usr/sbin",
p"/sbin",
p"/usr/local/sbin",
p"/usr/local/bin",
p"/usr/bin",
p"/bin",
p"/usr/games"
]
$NOTMUCH_CONFIG = p"~/.config/notmuch/notmuch-config"
$PROJECT_PATHS = [p"~/projects"]
$KEYRING_PROPERTY_SCHEME = "Bitwarden"
$XONSH_COLOR_STYLE = 'nightfox_transparent'
if p"~/.config/xonsh/rc-private.xsh".is_file():
source ~/.config/xonsh/rc-private.xsh
if p"~/.config/xonsh/rc-root.xsh".is_file():
source ~/.config/xonsh/rc-root.xsh
def color_str(fg:str="DEFAULT", bg:str="DEFAULT") -> str:
"""
Return color string for print_color based on hex values
"""
return f"{{BACKGROUND_{bg}}}{{{fg}}}"
def color_to_ansi(color:str):
"""
Return color string for print_color based on hex values
"""
color_r = int(color[1:3], 16)
color_g = int(color[3:5], 16)
color_b = int(color[5:7], 16)
return f"2;{color_r};{color_g};{color_b}"
__PROMPT_VI_MODES = {
InputMode.INSERT:
color_str($NFOX_BG0, $NFOX_YELLOW) + "I"
+ color_str($NFOX_YELLOW) + "",
InputMode.INSERT_MULTIPLE:
color_str($NFOX_BG0, $NFOX_YELLOW) + "I+"
+ color_str($NFOX_YELLOW) + "",
InputMode.REPLACE:
color_str($NFOX_BG0, $NFOX_BLUE) + "R"
+ color_str($NFOX_BLUE) + "",
InputMode.REPLACE_SINGLE:
color_str($NFOX_BG0, $NFOX_CYAN) + "r"
+ color_str($NFOX_CYAN) + "",
InputMode.NAVIGATION:
color_str($NFOX_BG0, $NFOX_MAGENTA) + "N"
+ color_str($NFOX_MAGENTA) + "",
}
def __get_user_prompt():
import os
user_name = os.getlogin()
if "SSH_CLIENT" in ${...}:
$IS_REMOTE = True
host_color = $NFOX_ORANGE
else:
$IS_REMOTE = False
host_color = $NFOX_BLUE
if user_name == "root":
$IS_ROOT = True
user_color = color_str($NFOX_BG0, $NFOX_RED)
user_sep = color_str($NFOX_RED, host_color) + ""
else:
$IS_ROOT = False
user_color = color_str($NFOX_BG0, $NFOX_CYAN)
user_sep = color_str($NFOX_CYAN, host_color) + ""
return user_color + user_name + user_sep
$PROMPT_FIELDS["user"] = __get_user_prompt()
def __get_host_prompt():
import socket
if $IS_REMOTE:
host_color = color_str($NFOX_BG0, $NFOX_ORANGE)
host_sep = color_str($NFOX_ORANGE, $NFOX_FG3) + ""
else:
host_color = color_str($NFOX_BG0, $NFOX_BLUE)
host_sep = color_str($NFOX_BLUE, $NFOX_FG3) + ""
return host_color + socket.gethostname().split(".", 1)[0] + host_sep
$PROMPT_FIELDS["hostname"] = __get_host_prompt()
if $IS_ROOT:
__PROMPT_CWD_COLOR = color_str($NFOX_BG0, $NFOX_RED)
__PROMPT_CWD_SEP = color_str($NFOX_RED, $NFOX_BG2) + ""
else:
__PROMPT_CWD_COLOR = color_str($NFOX_BG0, $NFOX_GREEN)
__PROMPT_CWD_SEP = color_str($NFOX_GREEN, $NFOX_BG2) + ""
def __get_cwd_prompt():
from xonsh.prompt.cwd import _dynamically_collapsed_pwd
cwd = _dynamically_collapsed_pwd()
return __PROMPT_CWD_COLOR + cwd + __PROMPT_CWD_SEP
$PROMPT_FIELDS["cwd"] = __get_cwd_prompt
__PROMPT_ENV_COLOR = color_str($NFOX_BG0, $NFOX_FG3)
__PROMPT_ENV_SEP = color_str($NFOX_FG3, $NFOX_GREEN) + ""
__PROMPT_ENV_SEP_ERROR = color_str($NFOX_FG3, $NFOX_RED) + ""
def __get_env_prompt():
string_venv = ""
string_rbenv = ""
string_nvm = ""
env_result = ""
string_rbenv = str(!(rbenv local err> /dev/null))
if not string_rbenv:
string_rbenv = str(!(rbenv global err> /dev/null))
string_rbenv = string_rbenv.replace('\n', '')
if string_rbenv == "system":
string_rbenv = ""
if "nvm_current_version" in ${...}:
string_nvm = $nvm_current_version
if "VIRTUAL_ENV" in ${...}:
string_venv = $VIRTUAL_ENV.split('/')[-1]
if string_nvm or string_rbenv or string_venv:
env_result = f" {string_nvm}| {string_rbenv}| {string_venv}"
if $LAST_RETURN_CODE == 0:
return __PROMPT_ENV_COLOR + env_result + __PROMPT_ENV_SEP
return __PROMPT_ENV_COLOR + env_result + __PROMPT_ENV_SEP_ERROR
$PROMPT_FIELDS["env_name"] = __get_env_prompt
__PROMPT_LAST_STATE_SUCCESS = color_str($NFOX_BG0, $NFOX_GREEN) + "xonsh✔" \
+ color_str($NFOX_GREEN) + ""
__PROMPT_LAST_STATE_ERROR = color_str($NFOX_BG0, $NFOX_RED) + "xonsh✗"
__PROMPT_LAST_STATE_ERROR_SUFFIX = color_str($NFOX_RED) + ""
def __get_last_state_prompt():
if $LAST_RETURN_CODE == 0:
return __PROMPT_LAST_STATE_SUCCESS
return __PROMPT_LAST_STATE_ERROR + str($LAST_RETURN_CODE) \
+ __PROMPT_LAST_STATE_ERROR_SUFFIX
$PROMPT_FIELDS["last_state"] = __get_last_state_prompt
$PROMPT_FIELDS["vi_mode"] = lambda: __PROMPT_VI_MODES.get(
__xonsh__.shell.shell.prompter.app.vi_state.input_mode,
color_str($NFOX_BG0, $NFOX_GREEN) + "E"
+ color_str($NFOX_GREEN) + ""
)
$PROMPT_FIELDS['gitstatus.branch'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + ""
$PROMPT_FIELDS['gitstatus.conflicts'].prefix = color_str($NFOX_RED, $NFOX_BG2) + "x"
$PROMPT_FIELDS['gitstatus.operations'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + ""
$PROMPT_FIELDS['gitstatus.changed'].prefix = color_str($NFOX_GREEN, $NFOX_BG2) + "-"
$PROMPT_FIELDS['gitstatus.deleted'].prefix = color_str($NFOX_RED, $NFOX_BG2) + "+"
$PROMPT_FIELDS['gitstatus.staged'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "●"
$PROMPT_FIELDS['gitstatus.lines_added'].prefix = color_str($NFOX_GREEN, $NFOX_BG2) + "+"
$PROMPT_FIELDS['gitstatus.lines_removed'].prefix = color_str($NFOX_RED, $NFOX_BG2) + "-"
$PROMPT_FIELDS['gitstatus.clean'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "C"
$PROMPT_FIELDS['gitstatus_sep'] = color_str($NFOX_BG2) + "\n"
$PROMPT_FIELDS['gitstatus.ahead'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "↑·"
$PROMPT_FIELDS['gitstatus.behind'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "↓·"
$PROMPT_FIELDS['gitstatus.numstat'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "N"
$PROMPT_FIELDS['gitstatus.porcelain'].prefix = color_str($NFOX_ORANGE, $NFOX_BG2) + "p"
$PROMPT_FIELDS['gitstatus.repo_path'].prefix = color_str($NFOX_GREEN, $NFOX_BG2) + "P"
$PROMPT_FIELDS['gitstatus.short_head'].prefix = color_str($NFOX_PINK, $NFOX_BG2) + "h"
$PROMPT_FIELDS['gitstatus.stash_count'].prefix = color_str($NFOX_YELLOW, $NFOX_BG2) + "S"
$PROMPT_FIELDS['gitstatus.tag'].prefix = color_str($NFOX_BLUE, $NFOX_BG2) + "T"
$PROMPT_FIELDS['gitstatus.tag_or_hash'].prefix = color_str($NFOX_CYAN, $NFOX_BG2) + "T"
$PROMPT_FIELDS['gitstatus.untracked'].prefix = color_str($NFOX_YELLOW, $NFOX_BG2) + "…"
$VC_GIT_INCLUDE_UNTRACKED = True
$UPDATE_OS_ENVIRON = True
$UPDATE_PROMPT_ON_KEYPRESS = True
$PROMPT_REFRESH_INTERVAL = 1
$PROMPT = "{user}{hostname}{env_name}{last_state}\n{cwd}{gitstatus}{gitstatus_sep}{vi_mode}"
$MULTILINE_PROMPT = color_str($NFOX_YELLOW) + "█"
#$ENABLE_ASYNC_PROMPT = True
$INDENT = " "
$XONSH_STDERR_PREFIX = color_str($NFOX_RED) + "ERR:"
$XONSH_STDERR_POSTFIX = "{RESET}"
$AUTO_SUGGEST_IN_COMPLETIONS = True
$CMD_COMPLETIONS_SHOW_DESC = True
$COMPLETIONS_DISPLAY = "multi"
$COMPLETION_IN_THREAD = True
$CASE_SENSITIVE_COMPLETIONS = False
$MOUSE_SUPPORT = True
$XONSH_AUTOPAIR = True
$LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:';
pushd "~/.config/xonsh"
import rc_private
import rc_desktop
if $IS_ROOT:
import rc_root
import rc_common_aliases
popd
json-fortune

View file

@ -1,107 +0,0 @@
#!/usr/bin/env xonsh
aliases["diff"] = "colordiff"
aliases["gitci"] = "git commit -S"
aliases["gitcia"] = "git commit -Sa"
aliases["gitco"] = "git checkout"
aliases["gitdiff"] = "git diff"
aliases["gitgrep"] = "git grep"
aliases["gitlog"] = "git log --name-status"
aliases["gitlstags"] = "git describe --tags"
aliases["gittag"] = "git tag -a"
aliases["gittree"] = "git log --graph"
aliases["gitw"] = "git instaweb --httpd=webrick"
aliases["l"] = "ls --color -pa"
aliases["less"] = "nvimpager"
aliases["lg"] = "lazygit"
aliases["ll"] = "ls --color -pla"
aliases["ls"] = "ls --color -p"
aliases["lzd"] = "lazydocker"
aliases["make"] = "colormake"
aliases["mbsync"] = "mbsync -c ~/.config/mbsync/mbsyncrc"
aliases["more"] = "nvimpager"
aliases["tig"] = "TERM=tmux-256color tig"
aliases["txor"] = "tmuxinator"
aliases["vim"] = "lvim -p"
aliases["vimdiff"] = "lvim -d -o"
def _gitgrephistory(args):
if len(args) == 1:
git rev-list --all | xargs git grep @(args[1])
else:
git rev-list --all | sed 's!$!:'@('"' + args[0] + '"')'!' | xargs git grep @(' '.join(args[1:]))
aliases["gitgrephistory"] = _gitgrephistory
def _gitpr(args):
"""git pull rebase and update modules"""
git pull --stat --progress --rebase @(' '.join(args))
git submodule update
aliases["gitpr"] = _gitpr
def _gitprp(args):
"""
git pull, rebase, update modules and push
"""
git pull --stat --progress --rebase @(' '.join(args))
git submodule update
git push
aliases["gitprp"] = _gitprp
def _gitprst(args):
"""
git stash, pull, rebase, update modules and apply stash
"""
git stash
git pull --stat --progress --rebase @(' '.join(args))
git submodule update
git stash apply
aliases["gitprst"] = _gitprst
def _gitprstp(args):
"""
git stash, pull, rebase, update modules, apply stash and push
"""
git stash
git pull --stat --progress --rebase @(' '.join(args))
git submodule update
git stash apply
git push
aliases["gitprstp"] = _gitprstp
def _gitpull(args):
"""
git pull and update submodules
"""
git pull --stat --progress @(' '.join(args))
git submodule update
aliases["gitpull"] = _gitpull
def _gitst(args):
"""
git status
"""
git status @(' '.join(args)) | nvimpager
aliases["gitst"] = _gitst
def _pip_upgrade(args):
"""
Upgrade python user-installed packaged
"""
pip freeze --user | cut -d'=' -f1 | xargs -n1 pip install -U --user @(' '.join(args))
aliases["pip_upgrade"] = _pip_upgrade
def _pip_upgrade_venv(args):
"""
Upgrade virtualenv
"""
pip freeze | cut -d'=' -f1 | xargs -n1 pip install -U @(' '.join(args))
aliases["pip_upgrade_venv"] = _pip_upgrade_venv

View file

@ -7,8 +7,8 @@ ignore * # ignore tous les headers, unignore plus tard
set sendmail = "send-from-mutt"
my_hdr X-Operating-System: `lsb_release -a | grep "^Description:" | sed "s/Description:[\t ]*//"`
my_hdr Markdown: false
my_hdr reStructuredText: false
my_hdr X-Pandoc-From: rst
my_hdr X-Pandoc-To: none
# h key show all headers
hdr_order Date From X-Sender Old-Return-Path Reply-To Mail-Followup-To To Cc Bcc Tags
@ -233,7 +233,6 @@ set nm_query_window_timebase="month"
set spoolfile=+Inbox
set postponed=+Drafts
set record=+Sent
set trash=+Trash
virtual-mailboxes "Boîte combinée" "notmuch://?query=tag:inbox"
virtual-mailboxes "Aujourd'hui" "notmuch://?query=date:today"

View file

@ -1,20 +0,0 @@
#!/usr/bin/env xonsh
#
aliases["newsboat"] = "TERM=tmux-256color newsboat"
aliases["epy"] = "TERM=tmux-256color epy"
aliases["pms"] = "TERM=xterm-direct pms"
aliases["poezio"] = "TERM=tmux-256color poezio"
aliases["tsumugi"] = "mpv https://azuracast.mahoro-net.org/listen/tsumugi/radio.mp3"
def _mpc(args):
mpc -f "%title%[ -%album%]\n\r%artist%[ - %performer%]\n\r%file%" @(" ".join(args))
aliases["mpc"] = _mpc
def _android_cast(args):
"""
Cast Android screen
"""
adb shell "while true; do screenrecord --output-format=h264 -; done" | ffplay -framerate 60 -probesize 32 -sync video -
aliases["android_cast"] = _android_cast