From 5704fafe4ddfad36f8167a1adac0efb8ecc699a7 Mon Sep 17 00:00:00 2001 From: Martinez Date: Wed, 30 Dec 2015 09:49:26 +0100 Subject: [PATCH] render.py: bind command line editor to ^E add mouse support to editor add wt-prefix64 add command line history completion dotfiles: fix getlogin bug in some terminals --- dotfiles/etc/zsh/zshrc | 12 ++++++++++-- libexec/render.py | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/dotfiles/etc/zsh/zshrc b/dotfiles/etc/zsh/zshrc index 69e9197..4d848d8 100644 --- a/dotfiles/etc/zsh/zshrc +++ b/dotfiles/etc/zsh/zshrc @@ -24,9 +24,10 @@ alias Yall="youtube-dl -o \"%(autonumber)s-%(title)s.%(ext)s\"" alias units="units -v" # Edit the current command line in $EDITOR +export VISUAL="nano -m" # enable mouse cursor autoload -U edit-command-line zle -N edit-command-line -bindkey '\C-x\C-e' edit-command-line +bindkey '\C-e' edit-command-line mkcd () { mkdir -p "$1" && cd "$1" @@ -66,8 +67,13 @@ zres () { } # winetricks tools -wt-prefix() { +wt-prefix64() { export WINEPREFIX="$HOME/.local/share/wineprefixes/$1" + unset WINEARCH +} + +wt-prefix() { + wt-prefix64 "$1" export WINEARCH="win32" } @@ -129,6 +135,8 @@ bindkey "\eOH" beginning-of-line bindkey "\eOF" end-of-line bindkey "\eOd" backward-word bindkey "\eOc" forward-word +bindkey '\e[A' history-beginning-search-backward +bindkey '\e[B' history-beginning-search-forward # paludis default options export CAVE_OPTIONS="--log-level warning" diff --git a/libexec/render.py b/libexec/render.py index 47e1afd..8b41087 100755 --- a/libexec/render.py +++ b/libexec/render.py @@ -3,6 +3,7 @@ import datetime import os +import pwd import socket import subprocess import sys @@ -45,6 +46,12 @@ MOUNT_IGNORE_DIR = ["/dev", "/proc", "/sys"] GIT_BLACKLIST = ["/var/paludis/repositories"] +def get_username(): + try: + return os.getlogin() + except FileNotFoundError: + return pwd.getpwuid(os.geteuid())[0] + def style_color(fg): return "\033[38;5;%dm" %(fg) @@ -179,7 +186,7 @@ class LoginPart(Part): self.fragments.append(style_color(COLOR_USER_USER)) self.fragments.append(style_bold()) - user = os.getlogin() + user = get_username() self.fragments.append(user) self.fragments.append(style_reset()) @@ -276,7 +283,7 @@ class PathPart(Part): if path in homes: self.dirs = [] - if homes[path] == os.getlogin(): + if homes[path] == get_username(): self.dirs.append(Dir(path, "", "~")) else: self.dirs.append(Dir(path, homes[path], "~"))