]> git.phdru.name Git - dotfiles.git/commitdiff
.fvwmrc: Refactor many SetVolumeAndBrowser functions into one with parameters master
authorOleg Broytman <phd@phdru.name>
Thu, 17 Apr 2025 18:04:40 +0000 (21:04 +0300)
committerOleg Broytman <phd@phdru.name>
Thu, 24 Apr 2025 11:42:23 +0000 (14:42 +0300)
53 files changed:
.bash_completion.d/python-pip
.bashrc
.fvwm/main.m4
.fvwm/menus
.inputrc
.mc/bashrc [new file with mode: 0644]
.mc/menu
.profile
.shellrc
.vim/plugin/netrw-config.vim [new file with mode: 0644]
.vim/python/virtualenv.py
bin/GET.py
bin/HEAD.py
bin/PS
bin/abspath.py
bin/browser-stack.py
bin/cleanup-recode.sh
bin/cmp.py
bin/compyle4vim.py
bin/cp_recode_fname
bin/decode-URLs.py
bin/get_encodings [new file with mode: 0755]
bin/get_html_encoding.py
bin/get_xml_encoding.py
bin/iconv.py
bin/iconvx.py
bin/idna.py
bin/koi2lat
bin/l8 [deleted file]
bin/lat2koi
bin/mc_type.py
bin/mplay
bin/mutt8 [deleted file]
bin/recode-filenames-recursive.py
bin/recode-inplace
bin/recode_filenames.py
bin/text-wrap.py
bin/tt
bin/unicode_norm_nfd.py
bin/unzip.py
bin/vim8 [deleted file]
bin/webbrowser
bin/webbrowser-encode-url
bin/wget-download
bin/whereis [new symlink]
bin/zip.py
lib/X11/xterm
lib/config/conda [new file with mode: 0644]
lib/config/gpg-agent
lib/config/hosts [new file with mode: 0644]
lib/config/python
lib/config/python3 [new file with mode: 0644]
lib/python/init.py

index f6e3126a014cf5fdd4dc6b36c6241b0c8159256f..67f3c698eb429723fe7d7d8180b6a5d0afa4a38b 100644 (file)
@@ -1,14 +1,15 @@
-PY_VERSIONS="2,2.7,3,"
-PY_VERSIONS+="$(eval echo 3.{`seq -s, 4 12`} | sed 's/ /,/g')"
+PY_VERSIONS=",2,2.7,3,"
+PY_VERSIONS+="$(eval echo 3.{`seq -s, 4 13`} | sed 's/ /,/g')"
 
-eval delegate_completion python python{$PY_VERSIONS}
+eval delegate_completion python{$PY_VERSIONS}
 
 _pip_completion_loader() {
     if [ "`type -t _pip_completion`" != function ]; then
-        eval "`pip3 completion --bash`"
+        for pip in `eval type -fP pip{3,2,}`; do break; done
+        eval "`$pip completion --bash`"
     fi
-    eval complete -F _pip_completion pip pip{$PY_VERSIONS}
+    eval complete -F _pip_completion pip{$PY_VERSIONS}
     unset _pip_completion_loader PY_VERSIONS
     return 124
 }
-eval complete -F _pip_completion_loader pip pip{$PY_VERSIONS}
+eval complete -F _pip_completion_loader pip{$PY_VERSIONS}
diff --git a/.bashrc b/.bashrc
index 8c05ad26d5155c59cb452177b160c0db87364f96..a403c7724bce1f7922658760a01cdab90bb8df65 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -37,12 +37,18 @@ esac
 if [ "$HISTFILE" = "$HOME/.bash_history" ]; then
     history -r
     unset HISTFILE
+else
+    alias uh="unset HISTFILE; unalias uh"
 fi
 
 # check the window size after each command and, if necessary,
 # update the values of LINES and COLUMNS.
 shopt -s checkwinsize
 
+# extended pattern matching, used in $HISTIGNORE
+shopt -s extglob
+HISTIGNORE='&: *:?*( ):??*( ):clear*( ):exit*( ):logout*( ):llp*( )'
+
 # If set, the pattern "**" used in a pathname expansion context will
 # match all files and zero or more directories and subdirectories.
 #shopt -s globstar
@@ -53,9 +59,7 @@ shopt -s histappend
 [ "`type -t ls`" = alias ] && unalias ls
 [ "`type -t ll`" = alias ] && unalias ll
 
-back() { cd - "$@"; }
-functions() { typeset -f "$@"; }
-j() { jobs; }
+alias functions='typeset -f'
 
 if [ -r "$HOME"/admin/prog/bash_prompt ]; then
     . "$HOME"/admin/prog/bash_prompt
@@ -157,7 +161,9 @@ fi
 unset _BASH_COMPLETIONS_DIR has_completion delegate_completion
 
 if [ -d "$HOME/lib/config" ]; then
-    complete -W "`cd \"$HOME/lib/config\" && echo *`" include
+    complete \
+        -W "`cd \"$HOME/lib/config\" && find . -type f -printf '%P\n'`" \
+        include
 fi
 complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser
 
@@ -188,26 +194,32 @@ fi
 
 
 if test -x /usr/bin/screen >/dev/null 2>&1; then
-    screen_newwin() {
-        history -a
-        screen "$@"
-    }
+    alias screen_newwin='history -a; screen'
 fi
 
-if [ "$SHLVL" -eq 1 -a "`type -t X`" = function ] && which startx >/dev/null 2>&1; then
-    # From https://stackoverflow.com/a/18839557
+if [ "$SHLVL" -eq 1 ] && which startx >/dev/null 2>&1; then
+    case "`type -t X`" in
+        alias)
+            alias _non_bash_X="`alias X | sed -e \"s/^alias X='//\" -e \"s/'\$//\"`"
+            alias X='history -a; _non_bash_X; history -r'
+        ;;
+
+        function)
+            # From https://stackoverflow.com/a/18839557
 
-    copy_function() {
-        test -n "$(declare -f "$1")" || return
-        eval "${_/$1/$2}"
-    }
+            copy_function() {
+                test -n "$(declare -f "$1")" || return
+                eval "${_/$1/$2}"
+            }
 
-    rename_function() {
-        copy_function "$@" || return
-        unset -f "$1"
-    }
+            rename_function() {
+                copy_function "$@" || return
+                unset -f "$1"
+            }
 
-    rename_function X _non_bash_X
+            #rename_function X _non_bash_X
 
-    X() { history -a; _non_bash_X; history -r; }
+            #X() { history -a; _non_bash_X; history -r; }
+        ;;
+    esac
 fi
index 8e7c740d554987f64e61a16d6698db271ab97610..0d1aec262f062cc477dffc185c8f14590e1c504b 100644 (file)
@@ -505,7 +505,7 @@ AddToFunc RestartFunction
 DestroyFunc UrgencyFunc
 AddToFunc UrgencyFunc
 +                             I Iconify off
-+                             I ThisWindow ("*Downloads|Skype") Break 1
++                             I ThisWindow ("*Downloads") Break 1
 +                             I FlipFocus
 +                             I Raise
 +                             I WarpToWindow 5p 5p
@@ -523,6 +523,8 @@ AddToFunc StartStandardSession
 +              I GotoDeskAndPage 2 0 1
 +              I TERM_KOI8_BIG
 +              I Wait TERM
++              I KeePassXC
++              I GotoDeskAndPage 0 0 0
 +              I FireFox
 
 DestroyFunc ResumeFunction
@@ -621,7 +623,7 @@ AddToFunc Term2HostsHome      I GotoDeskAndPage 1 1 2
 +                             I TERM_KOI8_SSH_SCREEN(iskra-aviel.phdru.name, iskra)
 +                             I Wait TERM
 +                             I GotoDeskAndPage 1 0 1
-+                             I TERM_KOI8_SSH_SCREEN(-D 1080 phdru.name, phdru.name)
++                             I TERM_KOI8_SSH_SCREEN(-D localhost:1080 phdru.name, phdru.name)
 +                             I Wait TERM
 +                             I GotoDeskAndPage 1 1 2
 
@@ -653,13 +655,20 @@ DestroyFunc Pidgin
 AddToFunc Pidgin              I GotoDeskAndPage 1 1 0
 +                             I Exec exec cgmem_nice 300 pidgin
 
-DestroyFunc Skype
-AddToFunc Skype               I GotoDeskAndPage 0 0 1
-+                             I Exec BROWSER=firefox exec cgmem_nice 2000 skypeforlinux
-
-DestroyFunc XFilename
+DestroyFunc XSetbgFilename
 AddToFunc XSetbgFilename      I Exec "$HOME"/current/projects/xsetbg/print-filename.py | text-wrap.py -w TEXT_WIDTH -s | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file -
 
+DestroyFunc KeePassXC
+AddToFunc KeePassXC           I Any ("*KeePassXC") Break
++                             I GotoDeskAndPage 1 0 0
++                             I Exec QT_SCALE_FACTOR=1.5 exec cgmem_nice 300 "$HOME"/tmp/KeePassXC-2.7.*-x86_64.AppImage
++                             I Wait KeePassXC
+
+DestroyFunc SetVolumeAndBrowser
+AddToFunc SetVolumeAndBrowser
++                             I Exec exec "$HOME"/current/projects/audio-cdr-video/audio/pa-volume set $0
++                             I PipeRead "echo $[1]Firefox"
+
 ##############################################################################
 # MENU Setup
 #
@@ -751,7 +760,7 @@ pushdef(`TERM_RU_UTF8', `Exec LC_CTYPE=ru_RU.UTF-8 exec TERM -name URxvt -xrm "*
 pushdef(`TERM_KOI8', `Exec LC_CTYPE=ru_RU.KOI8-R exec TERM -xrm "*Page: 1 0 1"')dnl
 pushdef(`TERM_RU_UTF8', `Exec LC_CTYPE=ru_RU.UTF-8 exec TERM -name URxvt -xrm "*Page: 1 0 1"')dnl
 +                       MENU_TERM_KOI8_SSH_SCREEN(phdru.name, phdru)
-+                       MENU_TERM_KOI8_SSH_SCREEN(-D 1080 phdru.name, phdru SOCKS5)
++                       MENU_TERM_KOI8_SSH_SCREEN(-D localhost:1080 phdru.name, phdru SOCKS5)
 +                       MENU_TERM_UTF8_BOTLT_SSH(phdru.name, phdru)
 +                       MENU_TERM_KOI8_BIG_SSH(phdru.name, PHDRU)
 popdef(`TERM_KOI8', `TERM_RU_UTF8')dnl
@@ -815,6 +824,7 @@ AddToMenu RootMenu "Root Menu"  Title
 +               ""              Nop
 +               "Browsers"      Popup Browsers
 +               "Utilities"     Popup Utilities
++               "Volume"        Popup Volume
 #+               ""              Nop
 #+               "Lock Screen"   Popup XlockMenu
 +               "XScreenSaver"  Popup XScreenSaverMenu
@@ -840,7 +850,16 @@ AddToMenu Utilities     "Choose one:" Title
 +                       "Refresh Screen" Refresh
 +                       "xrefresh" Exec exec xrefresh
 +                       ""       Nop
-+                       "Skype" Skype
++                       "KeePassXC" KeePassXC
+
+DestroyMenu Volume
+AddToMenu Volume        "Choose one:" Title
++                       "Silent (10%)" SetVolumeAndBrowser 6554 Resume
++                       "Quiet (32%)" SetVolumeAndBrowser 20972 Resume
++                       "Low (40%)" SetVolumeAndBrowser 26214 Resume
++                       "Normal (52%)" SetVolumeAndBrowser 34078 Resume
++                       "Loud (60%)" SetVolumeAndBrowser 39322 Resume
++                       "Very loud (80%)" SetVolumeAndBrowser 52429 Suspend
 +                       "pavucontrol" PaVuControl
 
 DestroyMenu  Browsers
@@ -879,24 +898,30 @@ AddToMenu XScreenSaverMenu     "Choose mode:" Title
 +                       "Reinitialize Screen Saver" Exec exec xscreensaver-command --restart
 
 AddToMenu XSetBgMenu    "XSetBg" Title
-+                       "Change wallpaper" Exec exec "$HOME"/current/projects/xsetbg/xsetbg-force
++                       "Change wallpaper" Exec exec "$HOME"/current/projects/xsetbg/xsetbg-http-force
 +                       "Start" Exec exec cgmem_nice 100 "$HOME"/current/projects/xsetbg/xsetbg-http-start
 +                       "Stop" Exec exec "$HOME"/current/projects/xsetbg/xsetbg-http-stop
 +                       "Restart" Exec exec "$HOME"/current/projects/xsetbg/xsetbg-http-restart
 +                       ""       Nop
 +                       "Xli" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" "$fn"
-+                       "Xli (scaled)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom auto "$fn"
++                       "Xli (auto-scale)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom auto "$fn"
++                       "Xli (50%)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom 50 "$fn"
++                       "Xli (200%)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom 200 "$fn"
 +                       "Open in browser" Exec exec cgmem_nice 4000 webbrowserX -n "$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r)"
 +                       "Filename" Exec exec "$HOME"/current/projects/xsetbg/print-filename.py -e koi8-r
 +                       "XFilename" Exec "$HOME"/current/projects/xsetbg/print-filename.py | text-wrap.py | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file -
 +                       "XFilename (wrapped)" XSetbgFilename
 +                       ""       Nop
 +                       "Xli (prev.)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r 1)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" "$fn"
-+                       "Xli (prev., scaled)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r 1)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom auto "$fn"
++                       "Xli (prev., auto-scale)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r 1)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom auto "$fn"
++                       "Xli (prev., 50%)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r 1)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom 50 "$fn"
++                       "Xli (prev., 200%)" Exec fn="$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r 1)" && exec xli -title "$(echo $fn | sed 's/[ .]/_/g')" -zoom 200 "$fn"
 +                       "Open in browser (prev.)" Exec exec cgmem_nice 4000 webbrowserX -n "$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r 1)"
 +                       "Filename (prev.)" Exec exec "$HOME"/current/projects/xsetbg/print-filename.py -e koi8-r 1
 +                       "XFilename (prev.)" Exec "$HOME"/current/projects/xsetbg/print-filename.py 1 | text-wrap.py | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file -
 +                       "XFilename (prev., wrapped)" Exec "$HOME"/current/projects/xsetbg/print-filename.py 1 | text-wrap.py -w TEXT_WIDTH -s | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file -
++                       ""       Nop
++                       "Disable" Exec $HOME/current/projects/xsetbg/enable.py --disable "$($HOME/current/projects/xsetbg/print-filename.py -e koi8-r)" && exec "$HOME"/current/projects/xsetbg/xsetbg-http-force
 
 ############################################################################
 # FvwmBacker
@@ -952,7 +977,6 @@ popdef(`TERM_KOI8')dnl
 *FvwmButtons: (Title Next,      Icon Jrecycle.xpm,     Action Exec exec "$HOME"/current/projects/xsetbg/xsetbg-http-force)
 #*FvwmButtons: (Title pavucontrol, Icon mini.sound.xpm, Action Exec "Volume Control" exec cgmem_nice 200 pavucontrol)
 #*FvwmButtons: (Title Id3Info,  Icon bell.xpm,         Action Id3Info)
-#*FvwmButtons: (Title Skype,    Icon skypeforlinux.png, Action Exec "Skype" FvwmCommand "GotoDeskAndPage 0 0 1" && BROWSER=firefox exec cgmem_nice 2000 skypeforlinux)
 *FvwmButtons: (Title AudioPlayer,  Icon bell.xpm,      Action Exec "deadbeef" LC_CTYPE=ru_RU.KOI8-R FvwmCommand "GotoDeskAndPage 0 1 1" && exec cgmem_nice 400 deadbeef)
 #*FvwmButtons: (Title XLock,     Icon Jxlock.xpm,      Action Exec exec xscreensaver-command -lock)
 
index 6e22ae60fc4e22bd796f2eaa20bdf3befcb9f307..e7d5edd1222d388a490eca20820de8a0a08869f5 100644 (file)
@@ -553,23 +553,23 @@ AddToMenu   Back-Solid
 
 DestroyMenu Back-Gradient
 AddToMenu   Back-Gradient
-#+ "&Red decay%mini.bball.xpm%" SetBackground 'Exec exec bggen red1 red4  | xv -root -quit  -'
-#+ "&Yellow Orange decay%mini.bball.xpm%" SetBackground 'Exec exec bggen Yellow1 Orange4  | xv -root -quit  -'
-#+ "&Green decay%mini.bball.xpm%" SetBackground 'Exec exec bggen green1 DarkGreen  | xv -root -quit  -'
-#+ "&Blue decay%mini.bball.xpm%" SetBackground 'Exec exec bggen 100 100 255  0 0 100  | xv -root -quit  -'
-#+ "&Magenta decayy%mini.bball.xpm%" SetBackground 'Exec exec bggen blue magenta | xv -root -quit -'
-#+ "&Blue to Red%mini.bball.xpm%" SetBackground 'Exec exec bggen blue red | xv -root -quit -'
-#+ "Blue to &Cyan%mini.bball.xpm%" SetBackground 'Exec exec bggen blue4 Cyan1 | xv -root -quit -'
-#+ "&Cyan to Blue%mini.bball.xpm%" SetBackground 'Exec exec bggen Cyan Blue4 | xv -root -quit -'
-#+ "&Black/pink/black%mini.bball.xpm%" SetBackground 'Exec exec bggen black pink black | xv -root -quit -'
-#+ "Black/&red/black%mini.bball.xpm%" SetBackground 'Exec exec bggen black red black | xv -root -quit -'
+#+ "&Red decay%mini.bball.xpm%" SetBackground 'Exec bggen red1 red4 | xv -root -quit  -'
+#+ "&Yellow Orange decay%mini.bball.xpm%" SetBackground 'Exec bggen Yellow1 Orange4 | xv -root -quit  -'
+#+ "&Green decay%mini.bball.xpm%" SetBackground 'Exec bggen green1 DarkGreen | xv -root -quit  -'
+#+ "&Blue decay%mini.bball.xpm%" SetBackground 'Exec bggen 100 100 255  0 0 100 | xv -root -quit  -'
+#+ "&Magenta decayy%mini.bball.xpm%" SetBackground 'Exec bggen blue magenta | xv -root -quit -'
+#+ "&Blue to Red%mini.bball.xpm%" SetBackground 'Exec bggen blue red | xv -root -quit -'
+#+ "Blue to &Cyan%mini.bball.xpm%" SetBackground 'Exec bggen blue4 Cyan1 | xv -root -quit -'
+#+ "&Cyan to Blue%mini.bball.xpm%" SetBackground 'Exec bggen Cyan Blue4 | xv -root -quit -'
+#+ "&Black/pink/black%mini.bball.xpm%" SetBackground 'Exec bggen black pink black | xv -root -quit -'
+#+ "Black/&red/black%mini.bball.xpm%" SetBackground 'Exec bggen black red black | xv -root -quit -'
 #+ "&Sun Raise 1%mini.bball.xpm%" SetBackground 'Exec exec bggen black orange black pink| xv -root -quit -'
 #+ "Sun Raise &2%mini.bball.xpm%" SetBackground 'Exec exec bggen black orange black Blue4| xv -root -quit -'
 #+ "Sun Raise &3%mini.bball.xpm%" SetBackground 'Exec exec bggen black red black grey60| xv -root -quit -'
-#+ "&Rainbowy%mini.bball.xpm%" SetBackground 'Exec exec bggen red green blue | xv -root -quit -'
-#+ "&Full Rainbowy%mini.bball.xpm%" SetBackground 'Exec exec bggen black red yellow green blue purple black | xv -root -quit -'
-#+ "&White to Black%mini.bball.xpm%" SetBackground 'Exec exec bggen white black | xv -root -quit -'
-#+ "&Black to White%mini.bball.xpm%" SetBackground 'Exec exec bggen white black | xv -root -quit -'
+#+ "&Rainbowy%mini.bball.xpm%" SetBackground 'Exec bggen red green blue | xv -root -quit -'
+#+ "&Full Rainbowy%mini.bball.xpm%" SetBackground 'Exec bggen black red yellow green blue purple black | xv -root -quit -'
+#+ "&White to Black%mini.bball.xpm%" SetBackground 'Exec bggen white black | xv -root -quit -'
+#+ "&Black to White%mini.bball.xpm%" SetBackground 'Exec bggen white black | xv -root -quit -'
 
 #------------------------------------------------------------------------------
 #--------- Banner  settings
@@ -761,10 +761,10 @@ AddToMenu   Backcolor
 + "&Blue%mini.bball.xpm%"              Exec exec xsetroot -solid Blue
 + "&Magenta%mini.bball.xpm%"           Exec exec xsetroot -solid Magenta
 + "&White%mini.bball.xpm%"             Exec exec xsetroot -solid White
-#+ "&Blue decay%mini.bball.xpm%"               Exec exec bggen 100 100 255  0 0 100  | xv -root -quit  -
-#+ "&Rainbow%mini.bball.xpm%" Exec exec bggen red green blue | xv -root -quit -
-#+ "&Full Rainbow%mini.bball.xpm%" Exec exec bggen black red yellow green blue purple black | xv -root -quit -
-#+ "&Magenta decay%mini.bball.xpm%" Exec exec bggen blue magenta | xv -root -quit -
+#+ "&Blue decay%mini.bball.xpm%"               Exec bggen 100 100 255  0 0 100 | xv -root -quit  -
+#+ "&Rainbow%mini.bball.xpm%" Exec bggen red green blue | xv -root -quit -
+#+ "&Full Rainbow%mini.bball.xpm%" Exec bggen black red yellow green blue purple black | xv -root -quit -
+#+ "&Magenta decay%mini.bball.xpm%" Exec bggen blue magenta | xv -root -quit -
 
 #--------- Background animation
 
index 5bfecb9cf8123013eabc30c6ef97db5c24b9c073..cf923ea3570c5dbc6a9fe4e718683d605ca5bf99 100644 (file)
--- a/.inputrc
+++ b/.inputrc
@@ -32,6 +32,8 @@ set visible-stats on
 
 Tab: complete
 M-Tab: menu-complete
+# This is Shift-Tab
+"\e[Z": menu-complete-backward
 
 # Some terminals have ugly default behaviour for C-h.
 #"\C-h": backward-delete-char
diff --git a/.mc/bashrc b/.mc/bashrc
new file mode 100644 (file)
index 0000000..96d990b
--- /dev/null
@@ -0,0 +1,7 @@
+# mc-specific bashrc
+
+# Source generic rc
+. ~/.bashrc
+
+# mc-specific settings
+unset HISTFILE
index c2198c8978457c3e3ae2b81f25ad519b2ef36151..015b02ba8ea4a0f7fcb28fde63033c27e8207bd4 100644 (file)
--- a/.mc/menu
+++ b/.mc/menu
@@ -26,16 +26,16 @@ g  Edit the file in gvim
 
 + t lr
 b  View the file in a browser
-   exec webbrowser-encode-url -e utf-8 file://%d/%f
+   exec webbrowser-encode-url file://%d/%f
 
 + t lr
 = f \.(htm(l?)|txt)$
 w  View the file in a new browser window
-   exec webbrowser-encode-url -e utf-8 -n file://%d/%f
+   exec webbrowser-encode-url -n file://%d/%f
 
 + t lr
 t  View the file in a new browser tab
-   exec webbrowser-encode-url -e utf-8 -t file://%d/%f
+   exec webbrowser-encode-url -t file://%d/%f
 
 + t lr
 p  View the file in a new private browser tab
@@ -311,7 +311,7 @@ z  Compress the current subdirectory to zip
    echo -n "Name of the distribution file (without extension) [$Pwd]: "
    read zip
    if [ "$zip"x = x ]; then zip="$Pwd"; fi
-   cd .. && zip -r9 "$zip".zip "$Pwd" &&
+   cd .. && zip -ry9 "$zip".zip "$Pwd" &&
    echo ../"$zip".zip created.
 
 + t d & f ^\.\.$
@@ -358,7 +358,7 @@ z  xz the file
 
 + ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr
 z  zip the file/directory
-   exec zip -r9 %f.zip %f
+   exec zip -ry9 %f.zip %f
 
 + ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr
 y  zip the file/directory recoding filename(s)
@@ -367,7 +367,7 @@ y  zip the file/directory recoding filename(s)
 + t t
 Z  zip selected files/directories
    ZIP=%{Enter zip name}
-   exec zip -r9 "$ZIP" %s
+   exec zip -ry9 "$ZIP" %s
 
 + t t
 Y  zip selected files/directories recoding filenames
index 45b4a5686487f2e0558fbdc18e5db1ad525e728c..9d997e97e767c49be42352b204022bf2a30a1912 100644 (file)
--- a/.profile
+++ b/.profile
@@ -35,9 +35,9 @@ fi
 umask 077
 
 PATH="$HOME"/bin:"$HOME"/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-MANPATH="$HOME"/man:/usr/local/man:/usr/share/man:/usr/man
+MANPATH="$HOME"/man:/usr/local/man:/usr/share/man:/usr/man
 # LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
-export PATH MANPATH # LD_LIBRARY_PATH
+export PATH MANPATH # LD_LIBRARY_PATH
 
 LANG=C
 #LC_ALL=C
@@ -129,12 +129,16 @@ if [ -t 0 ] ; then
     VISUAL="$EDITOR"
     export EDITOR FCEDIT VISUAL
 
-    HISTCONTROL=ignoreboth
-    HISTIGNORE="`echo '&: *:~\?*:[bf]g:cd:clear:e:exit:logout:l:ls:ll:llp:[m,]c:��:w:X:x' | iconv -f koi8-r`"
+    FIGNORE='.o:~:.pyc:.pyo:.tmp*'
+    export FIGNORE
+
+    HISTCONTROL=erasedups:ignoreboth
+    HISTIGNORE='&: *:?:??:clear:exit:logout:llp'
     HISTFILE="$HOME/.sh_history"
     HISTFILESIZE=2000
     HISTSIZE=1000
-    export HISTCONTROL HISTIGNORE HISTFILE HISTFILESIZE HISTSIZE
+    HISTTIMEFORMAT='%Y-%m-%d %T '
+    export HISTCONTROL HISTIGNORE HISTFILE HISTFILESIZE HISTSIZE HISTTIMEFORMAT
 
     # Used by bash/mc for hostname completion
     HOSTFILE="$HOME"/lib/config/hosts
@@ -206,6 +210,10 @@ if [ -t 0 ] ; then
 
     unset name email
 
+    # Enable plumbing commands to be completed
+    GIT_COMPLETION_SHOW_ALL_COMMANDS=1
+    export GIT_COMPLETION_SHOW_ALL_COMMANDS
+
     #SCREENDIR="$HOME"/tmp/screen
     #export SCREENDIR
     #mkdir -p "$SCREENDIR"
@@ -217,6 +225,7 @@ fi
 #export DISPLAY
 
 if [ -n "$DISPLAY" ]; then
+    #xhost +local:root > /dev/null 2>&1
     PATH=$PATH:/usr/games
 
     # mutt, python and vim
@@ -251,7 +260,10 @@ if [ -n "$DISPLAY" ]; then
     #__GL_FSAA_MODE=4
     #export __GL_FSAA_MODE
 
-    #xhost +local:root > /dev/null 2>&1
+    # Bigger fonts for Qt
+    QT_QPA_PLATFORMTHEME=qt5ct
+    #QT_SCALE_FACTOR=1.5
+    export QT_QPA_PLATFORMTHEME #QT_SCALE_FACTOR
 fi
 
 [ -n "$HAS_LESS" ] && unset HAS_LESS
index 9f9242ae5e6a4d3d05448af6f06ceb2be68a222d..72c4a158f0fd434614bf0156a2b41f1a5d772908 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -40,12 +40,18 @@ case "$HOME" in
 esac
 
 if test -n "$KSH_VERSION" -o -n "$FCEDIT"; then
-    back() { cd - "$@"; }
-    j() { jobs; }
+    alias back='cd -'
+    alias j=jobs
 fi
 
 # clear screen and history, logout
-chlo() { clear; cd; >$HISTFILE; unset HISTFILE; history -c; logout || exit; }
+alias clhlo='clear; cd; >$HISTFILE; unset HISTFILE; history -c; logout || exit'
+
+# cgmem_nice
+alias c3='cgmem_nice 300'
+alias c5='cgmem_nice 500'
+alias e3='exec cgmem_nice 300'
+alias e5='exec cgmem_nice 500'
 
 if [ -n "$STY" -a "$WINDOW" != 0 ]; then
     #unset MAILCHECK everywhere except for the 1st GNU screen window
@@ -206,7 +212,7 @@ vim() {
 
 
 if [ "$SHLVL" -eq 1 ] && which startx >/dev/null 2>&1; then
-    X() { startx >> .Xserver.log 2>&1; cyr; /bin/rm -f .Xauthority; }
+    alias X='startx >> .Xserver.log 2>&1; cyr; /bin/rm -f .Xauthority'
 fi
 
-x() { exit; }
+alias x='logout || exit'
diff --git a/.vim/plugin/netrw-config.vim b/.vim/plugin/netrw-config.vim
new file mode 100644 (file)
index 0000000..97916e7
--- /dev/null
@@ -0,0 +1,3 @@
+" https://stackoverflow.com/a/62389532/7976758
+
+let g:netrw_browsex_viewer='webbrowser -p'
index ed46739fb6774130b760abc3caef0a0017d711a5..62316009e94bfe707b5cdc5cf6b465283375ab03 100644 (file)
@@ -3,12 +3,12 @@ import sys, os  # noqa: E401 multiple imports on one line
 virtualenv_dir = os.environ.get('VIRTUAL_ENV')
 if virtualenv_dir:
     if (
-        (sys.version_info[0] == 2)
-            and os.path.exists(
-                os.path.join(virtualenv_dir, 'lib', 'python2.7'))
-    ) or (
-        not os.path.exists(
-                os.path.join(virtualenv_dir, 'lib', 'python2.7'))
+        os.path.exists(
+            os.path.join(
+                virtualenv_dir, 'lib',
+                'python%d.%d' % (sys.version_info[0], sys.version_info[1])
+            )
+        )
     ):
         for activate_this in [
             os.path.join(virtualenv_dir, 'bin', 'activate_this.py'),
index 2f00d89b2975180179c78681d873d7e66db3d663..c20f0c1f5a558161e2d6360c2b330c53ac31e714 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 from urllib.parse import urlsplit, parse_qsl, quote, quote_plus, urlencode
 from urllib.request import urlretrieve
index 6c0e5f7eb0d3bd30dddf2ad7d64dd8b2608fb5ff..334472d8b3060f945154b780364f4dc036357fb8 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 from http.client import HTTPConnection, HTTPSConnection
 from urllib.parse import urlsplit, parse_qsl, urlencode, quote, quote_plus
diff --git a/bin/PS b/bin/PS
index 7fbd8b1cfb3b2b75c1303a2ad543af0f66f56f66..8fe10784f3dd36aae467ea4fc0ecad8ec67c151f 100755 (executable)
--- a/bin/PS
+++ b/bin/PS
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys, os
 
index cbda1c82a5aabe17b3ade882ca89264f923e3353..b5aeae6762c76f125ea17c0a43c22194cd2040a2 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys, os
 print(os.path.abspath(sys.argv[1]))
index 7120479aa70acf5486adbcaf0b0bf1756b262d8f..e0e6575f3091ef05b4d4688d88a7a5a0a46eb323 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 from __future__ import print_function
 import sys, os
index 3f8213d2d92cd638d66f9e583f1c2def14dbbe75..a957cbfbaaf7249c53945dd065d569920be3b37d 100755 (executable)
@@ -1,22 +1,15 @@
 #! /bin/sh
+set -e
 
 if ! echo "$LC_CTYPE" | grep -Fiq utf-8; then
-   echo "This script requires UTF-8 locale" 1>&2
-   exit 1
+    echo "This script requires UTF-8 locale" 1>&2
+    exit 1
 fi
 
-from_enc=utf-8
-to_enc=koi8-r
-
-while getopts f:t: opt; do
-   case $opt in
-      f ) from_enc="$OPTARG" ;;
-      t ) to_enc="$OPTARG" ;;
-   esac
-done
-shift `expr $OPTIND - 1`
+. get_encodings
 
 for dir in "${@:-.}"; do
-   cleanup-filenames-recursive.sh "$dir" &&
-   recode-filenames-recursive.py "$from_enc" "$to_enc" "$dir" || exit 1
+    cleanup-filenames-recursive.sh "$dir" &&
+    recode-filenames-recursive.py -f "$from_encoding" -t "$to_encoding" \
+        "$dir" || exit 1
 done
index 800e119ab5627f8dd6423cb6cf61001eb81a8205..45e3fd44847be75cfc290488331363a1ba11de9e 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 """cmp.py: compare two files. Replace cmp because standard cmp cannot compare
 large files.
 """
index 08f93244ec2735d170a937a6f3ddf98f1390e07d..8c7d2563a7b56be6ffe85d460e31dd34b622c78a 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys, os
 
index 8cae733e8642c03a8b6f90dcdd2eec230762cfa7..ad7f7d0fd6d877a09380a9be85877f2f504a5e03 100755 (executable)
@@ -1,40 +1,27 @@
 #! /bin/sh
 set -e
 
-usage() {
-   echo "Usage: $0 [[from_enc] to_enc] filename" >&2
-   exit 1
-}
-
-if [ $# -eq 1 ]; then
-    from_enc="`python3 -c \"from m_lib.defenc import default_encoding; print(default_encoding)"`"
-    if [ "$from_enc" != utf-8 ]; then
-        to_enc=utf-8
-    else
-        usage
-    fi
-    filename="$1"
-elif [ $# -eq 2 ]; then
-    from_enc="`python3 -c \"from m_lib.defenc import default_encoding; print(default_encoding)"`"
-    to_enc="$1"
-    filename="$2"
-elif [ $# -eq 3 ]; then
-    from_enc="$1"
-    to_enc="$2"
-    filename="$3"
-else
-    usage
-fi
-
 cmd="`basename \"$0\"`"
 case "$cmd" in
-    cp_*) cmd="cp -p" ;;
+    cp_*) cmd="cp -ap" ;;
     mv_*) cmd=mv ;;
     *)
-        echo "Uncnown command $0, aborting" >&2
+        echo "Unknown command $0, aborting" >&2
         exit 2
     ;;
 esac
 
-filename_recoded=`echo "$filename" | iconv -f "$from_enc" -t "$to_enc"`
-exec $cmd "$filename" "$filename_recoded"
+. get_encodings
+
+if [ -z "$1" ]; then
+    echo "Usage: $0 [-f from_encoding] [-t to_encoding] path [path ...]" >&2
+    exit 1
+fi
+
+for filename in "$@"; do
+    filename_recoded=`echo "$filename" |
+        iconv -f "$from_encoding" -t "$to_encoding"`
+    if [ "$filename_recoded" != "$filename" ]; then
+        $cmd "$filename" "$filename_recoded"
+    fi
+done
index ef04664342a87b7a5d5dc1c65045aa3399aee77d..1c164bdc9c02f1c1c4192e1ec1e61c8423ed81ba 100755 (executable)
@@ -1,9 +1,6 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
-try:
-    from urllib.parse import unquote
-except ImportError:
-    from urllib import unquote
+from urllib.parse import unquote
 import sys
 
 while True:
diff --git a/bin/get_encodings b/bin/get_encodings
new file mode 100755 (executable)
index 0000000..59c4be3
--- /dev/null
@@ -0,0 +1,63 @@
+#! /bin/sh
+
+case "$0" in
+    */get_encodings)
+        sourced=false
+        ;;
+    *)
+        sourced=true
+        ;;
+esac
+
+from_encoding=
+to_encoding=
+default_encoding="`python3 -c \"from m_lib.defenc import default_encoding; print(default_encoding)"`"
+
+while getopts f:t: opt; do
+   case $opt in
+      f ) from_encoding="$OPTARG" ;;
+      t ) to_encoding="$OPTARG" ;;
+   esac
+done
+shift `expr $OPTIND - 1`
+
+error() {
+    echo "$@" >&2
+    echo "Usage: $0 [-f from_encoding] [-t to_encoding] [path [path ...]]" >&2
+    exit 1
+}
+
+if [ -n "$from_encoding" ]; then
+    if [ -n "$to_encoding" ]; then
+        : # Everything is defined, no need to guess
+    elif [ "$from_encoding" = utf-8 ]; then
+        if [ "$default_encoding" = utf-8 ]; then
+            error Cannot guess to_encoding
+        else
+            to_encoding="$default_encoding"
+        fi
+    else
+        to_encoding=utf-8
+    fi
+elif [ -n "$to_encoding" ]; then
+    if [ "$to_encoding" = "$default_encoding" ]; then
+        if [ "$default_encoding" = utf-8 ]; then
+            error Cannot guess from_encoding
+        else
+            from_encoding=utf-8
+        fi
+    else
+        from_encoding="$default_encoding"
+    fi
+else
+    if [ "$default_encoding" = utf-8 ]; then
+        error Cannot guess encodings
+    else
+        from_encoding="$default_encoding"
+        to_encoding=utf-8
+    fi
+fi
+
+if [ "$sourced" = false ]; then
+    echo "$from_encoding $to_encoding"
+fi
index 381be9c10b19ea8fcbe78b05bc1f311ee28d1390..5fa5473f1969d7ae4a707b2a5e035adc924e68b7 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 from m_lib.net.www.html import HTMLParser as _HTMLParser
 
index cdd9b6b585e01ee7ddde67f654c645ea43bc326d..cff2123c2994bf3c7c44959f4af06afabebbef16 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 charset = None
 def xml_decl_handler(version, encoding, standalone):
index 9cb164fef0aa72bc6a2399d1ab4a988dd27d4c59..6f594c652a5d3284d8788aa85738b1843cc307ae 100755 (executable)
@@ -1,32 +1,26 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 "Recode to default charset"
 
 import sys
-from getopt import getopt
-from m_lib.defenc import default_encoding
 
-from_charset = "cp1251"
-to_charset = default_encoding
+from recode_filenames import parse_args
+from_encoding, to_encoding, files = parse_args(default='-')
 
-options, arguments = getopt(sys.argv[1:], 'f:t:')
-for option, value in options:
-    if option == '-f':
-        from_charset = value
-    elif option == '-t':
-        to_charset = value
 
 output = getattr(sys.stdout, 'buffer', sys.stdout)
 
 
-if arguments:
-    for file in arguments:
+if files != ['-']:
+    for file in files:
         with open(file, 'rb') as infile:
             for line in infile:
                 output.write(
-                    line.decode(from_charset, "replace").
-                    encode(to_charset, "replace"))
+                    line.decode(from_encoding, "replace").
+                    encode(to_encoding, "replace"))
 else:
     input = getattr(sys.stdin, 'buffer', sys.stdin)
     for line in input:
         output.write(
-            line.decode(from_charset, "replace").encode(to_charset, "replace"))
+            line.decode(from_encoding, "replace").
+            encode(to_encoding, "replace")
+        )
index b4c990e1aeee6e1c93dd4339ec52cbb5e035b14c..7ec3c96597fe40db6592b11b3c52efaa6746da81 100755 (executable)
@@ -1,38 +1,23 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 "iconv wrapper"
 
-from getopt import getopt
-import os, shutil, sys, tempfile
+import os, shutil, tempfile
 
-options, arguments = getopt(sys.argv[1:], 'f:t:')
-
-from_charset = to_charset = None
-
-for option, value in options:
-    if option == '-f':
-        from_charset = value
-    elif option == '-t':
-        to_charset = value
-
-
-if from_charset is None:
-    raise ValueError("you must use -f param to name source charset")
-
-if to_charset is None:
-    raise ValueError("you must use -t param to name destination charset")
+from recode_filenames import parse_args
+from_encoding, to_encoding, files = parse_args(default='-')
 
 
 tempfname = "_iconvx" + tempfile.gettempprefix() + "tmp"
 
-if arguments:
+if files != ['-']:
     try:
-        for file in arguments:
+        for file in files:
             os.system(
                 "iconv.py -f '%s' -t '%s' '%s' > '%s'" % (
-                    from_charset, to_charset, file, tempfname))
+                    from_encoding, to_encoding, file, tempfname))
             shutil.copy2(tempfname, file)
     finally:
         os.unlink(tempfname)
 
 else:  # filter stdin => stdout
-    os.system("iconv.py -f '%s' -t '%s'" % (from_charset, to_charset))
+    os.system("iconv.py -f '%s' -t '%s'" % (from_encoding, to_encoding))
index 44843ac223fa4932ba872d64b6eea889fbb2b352..6019f050318e1f2214c35c29d169688593d4f7a4 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys
 from m_lib.defenc import default_encoding
index 46871001968ed74b285dc673090466340121dab0..81e1c823526dfbf65d0b9f119eb7b412f239c984 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys
 from m_lib.rus import rus2lat
diff --git a/bin/l8 b/bin/l8
deleted file mode 100755 (executable)
index d8b8566..0000000
--- a/bin/l8
+++ /dev/null
@@ -1,4 +0,0 @@
-#! /bin/sh
-
-. "$HOME"/lib/X11/koi8.vars
-exec luit -encoding koi8-r "$@"
index 9c43755353d7d3f6deb52e5f202d4ef867b19ba9..bb9f1adec7a006c265baff1d2f160d74488f68e0 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys
 from m_lib.rus import lat2rus
index d2e98843390068e52df3e42f8c9ae01a12eff465..04347cfc80d025f502ae82ddda723307e61427c9 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys, subprocess
 
index e4ca11004c5b1d39c3198b168f33c776fa48261c..decfbfe8e22fa83a39d12f50821d116c571a4a92 100755 (executable)
--- a/bin/mplay
+++ b/bin/mplay
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-options="--ao pulse --quiet"
+options="--ao=pulse --quiet"
 
 if [ -n "$AUDIO_VOLUME" ]; then
    options="$options --af=loudnorm --volume=$AUDIO_VOLUME"
diff --git a/bin/mutt8 b/bin/mutt8
deleted file mode 100755 (executable)
index 0fa81c4..0000000
--- a/bin/mutt8
+++ /dev/null
@@ -1,4 +0,0 @@
-#! /bin/sh
-
-. "$HOME"/lib/X11/utf-8.vars
-exec mutt "$@"
index b7787e491cea8b6c53d3863dcab94dd0b7c96b56..5afeed12d9a818619cb4d61b2dc776d0ce02a375 100755 (executable)
@@ -1,37 +1,39 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
-import sys, os
-from recode_filenames import _recode
+import os
 
-if len(sys.argv) == 3:
-    start_dir = '.'
-elif len(sys.argv) == 4:
-    start_dir = sys.argv[3]
-else:
-    sys.exit("Usage: %s src_enc dst_enc [start_dir]" % sys.argv[0])
+from recode_filenames import parse_args, build_recode
+
+from_encoding, to_encoding, dirnames = parse_args(default='.')
+_recode = build_recode(from_encoding, to_encoding)
 
 
 def _onerror(exc):
     raise exc
 
-plist = list(os.walk(start_dir, topdown=False, onerror=_onerror))
-
 
 save_dir = os.getcwd()
-for dirname, _subdirs, fnames in plist:
-    if dirname == '.':
-        continue
-    os.chdir(dirname)
-    for filename in fnames:
-        # if not exists - it was renamed already
-        if os.path.exists(filename) and \
-                os.path.isfile(filename):
-            newname = _recode(filename)
-            if newname != filename:
-                os.rename(filename, newname)
-    os.chdir('..')
-    dirname = os.path.basename(dirname)
-    newname = _recode(dirname)
-    if newname != dirname:
-        os.rename(dirname, newname)
-    os.chdir(save_dir)
+for start_dir in dirnames:
+    for dirname, _subdirs, fnames in list(
+        os.walk(start_dir, topdown=False, onerror=_onerror)
+    ):
+        if dirname != '.':
+            os.chdir(dirname)
+        for filename in fnames:
+            # if not exists - it was renamed already
+            if os.path.exists(filename) and \
+                    os.path.isfile(filename):
+                newname = _recode(filename)
+                if not isinstance(newname, str):
+                    newname = newname.decode()
+                if newname != filename:
+                    os.rename(filename, newname)
+        if dirname != '.':
+            os.chdir('..')
+            dirname = os.path.basename(dirname)
+            newname = _recode(dirname)
+            if not isinstance(newname, str):
+                newname = newname.decode()
+            if newname != dirname:
+                os.rename(dirname, newname)
+        os.chdir(save_dir)
index 77ff3063f46ce5dc62fb0191706959ec4e592a19..149b4aed29860a3955837b5408b764d34f6fb2bc 100755 (executable)
@@ -1,14 +1,12 @@
 #! /bin/sh
+set -e
 
-fromenc="$1"
-toenc="$2"
-shift 2
+tmpfile="`mktemp`"
+trap "exec rm -f $tmpfile" EXIT HUP INT QUIT PIPE TERM
 
-tmpfile="`mktemp`" &&
+. get_encodings
 
 for file in "$@"; do
-   iconv -f "$fromenc" -t "$toenc" "$file" >"$tmpfile" &&
+   iconv -f "$from_encoding" -t "$to_encoding" "$file" >"$tmpfile"
    cp "$tmpfile" "$file"
 done
-
-exec rm "$tmpfile"
index b8d3fa04daca8794a10479951126cb9e3a7932ac..1f2ece9c6c57a09cf262319d179c3bb4fce99585 100755 (executable)
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 # -*- coding: koi8-r -*-
 
+import argparse
 import sys
 
-src_encoding = sys.argv[1]
-dst_encoding = sys.argv[2]
+from m_lib.defenc import default_encoding
 
-if src_encoding == "translit":
-    if dst_encoding == "koi8-r":
-        from m_lib.rus.lat2rus import lat2koi as _recode
-    elif dst_encoding == "cp1251":
-        from m_lib.rus.lat2rus import lat2win as _recode
+
+def parse_args(default=None):
+    parser = argparse.ArgumentParser(description='Recode filenames')
+    parser.add_argument('-f', '--from-encoding', help='from encoding')
+    parser.add_argument('-t', '--to-encoding', help='to encoding')
+    parser.add_argument('filename', nargs='*' if default else '+',
+                        default=[default], help='filenames to recode')
+    args = parser.parse_args()
+
+    from_encoding = args.from_encoding
+    to_encoding = args.to_encoding
+
+    if from_encoding:
+        if to_encoding:
+            pass  # Everything is defined, no need to guess
+        elif from_encoding == 'utf-8':
+            if default_encoding == 'utf-8':
+                sys.exit('Cannot guess to_encoding')
+            else:
+                to_encoding = default_encoding
+        else:
+            to_encoding = 'utf-8'
+    elif to_encoding:
+        if to_encoding == default_encoding:
+            if default_encoding == 'utf-8':
+                sys.exit('Cannot guess from_encoding')
+            else:
+                from_encoding = 'utf-8'
+        else:
+            from_encoding = default_encoding
     else:
-        raise NotImplementedError("destination encoding must be koi8-r or cp1251, not `%s'" % dst_encoding)
+        if default_encoding == 'utf-8':
+            sys.exit('Cannot guess encodings')
+        else:
+            from_encoding = default_encoding
+            to_encoding = 'utf-8'
+
+    return from_encoding, to_encoding, args.filename
+
+
+def build_recode(from_encoding, to_encoding):
+    if from_encoding == "translit":
+        if to_encoding == "koi8-r":
+            from m_lib.rus.lat2rus import lat2koi as _recode
+        elif to_encoding == "cp1251":
+            from m_lib.rus.lat2rus import lat2win as _recode
+        else:
+            raise NotImplementedError(
+                "destination encoding must be koi8-r or cp1251, "
+                "not `%s'" % to_encoding)
+
+    elif to_encoding == "translit":
+        if from_encoding == "koi8-r":
+            from m_lib.rus.rus2lat import koi2lat as _recode
+        elif from_encoding == "cp1251":
+            from m_lib.rus.rus2lat import win2lat as _recode
+        else:
+            raise NotImplementedError(
+                "source encoding must be koi8-r or cp1251, "
+                "not `%s'" % from_encoding)
+
+        from m_lib.rus.rus2lat import koi2lat_d
+        koi2lat_d["�"] = ''  # remove apostrophs -
+        koi2lat_d["�"] = ''  # they are not very good characters in filenames
+        koi2lat_d["�"] = ''  # especially on Windoze
+        koi2lat_d["�"] = ''  # :-)
+
+    elif from_encoding == "url":
+        try:
+            from_encoding, to_encoding = to_encoding.split('/')
+        except ValueError:
+            from_encoding = to_encoding
+        from urllib.parse import unquote
+        from m_lib.opstring import recode
+
+        def _recode(s):
+            s = unquote(s)
+            if from_encoding != to_encoding:
+                s = recode(s, from_encoding, to_encoding, "replace")
+            return s
+
+    elif to_encoding == "url":
+        try:
+            from_encoding, to_encoding = from_encoding.split('/')
+        except ValueError:
+            to_encoding = from_encoding
+        from urllib.parse import quote
+        from m_lib.opstring import recode
+
+        def _recode(s):
+            if from_encoding != to_encoding:
+                s = recode(s, from_encoding, to_encoding, "replace")
+            #                wget treats them as safe
+            #                     vvvvvvvvvvvvv
+            return quote(s, safe=";/?:@&=+$,()'")
 
-elif dst_encoding == "translit":
-    if src_encoding == "koi8-r":
-        from m_lib.rus.rus2lat import koi2lat as _recode
-    elif src_encoding == "cp1251":
-        from m_lib.rus.rus2lat import win2lat as _recode
     else:
-        raise NotImplementedError("source encoding must be koi8-r or cp1251, not `%s'" % src_encoding)
-
-    from m_lib.rus.rus2lat import koi2lat_d
-    koi2lat_d["�"] = '' # remove apostrophs -
-    koi2lat_d["�"] = '' # they are not very good characters in filenames
-    koi2lat_d["�"] = '' # especially on Windoze
-    koi2lat_d["�"] = '' # :-)
-
-elif src_encoding == "url":
-    try:
-        src_encoding, dst_encoding = dst_encoding.split('/')
-    except ValueError:
-        src_encoding = dst_encoding
-    from m_lib.opstring import recode
-    import urllib
-    def _recode(s):
-        s = urllib.unquote(s)
-        if src_encoding != dst_encoding:
-            s = recode(s, src_encoding, dst_encoding, "replace")
-        return s
-
-elif dst_encoding == "url":
-    try:
-        src_encoding, dst_encoding = src_encoding.split('/')
-    except ValueError:
-        dst_encoding = src_encoding
-    from m_lib.opstring import recode
-    import urllib
-    def _recode(s):
-        if src_encoding != dst_encoding:
-            s = recode(s, src_encoding, dst_encoding, "replace")
-        return urllib.quote(s, safe=";/?:@&=+$,()'") # wget treats them as safe
-
-else:
-    from m_lib.opstring import recode
-    def _recode(s):
-        return recode(s, src_encoding, dst_encoding, "replace")
+        def _recode(s):
+            return s.encode(to_encoding, "surrogateescape").\
+                decode(from_encoding, "surrogateescape")
+
+    return _recode
 
 
 if __name__ == "__main__":
     import os
-    for filename in sys.argv[3:]:
+    from_encoding, to_encoding, filenames = parse_args()
+    _recode = build_recode(from_encoding, to_encoding)
+    for filename in filenames:
         new_name = _recode(filename)
-        if type(filename) is not type(new_name):
+        if not isinstance(new_name, str):
             new_name = new_name.decode()
         if new_name != filename:
+            sys.stdout.buffer.write(
+                b'%s %s / %s -> %s\n' % (
+                    from_encoding.encode(), to_encoding.encode(),
+                    filename.encode(default_encoding, 'replace'),
+                    new_name.encode(to_encoding, 'replace'))
+                )
             os.rename(filename, new_name)
index ecfafa8f0d9d70b9ab41eca855f27962508e8419..4d54e104994cc67c7f725bf23d4b802823df81c9 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 from __future__ import print_function
 
 import sys
diff --git a/bin/tt b/bin/tt
index 72eca819036be5ba8f805bab3d528adcdf574c9e..ef89da45d8160f927996ff0fb8b8775537d4519c 100755 (executable)
--- a/bin/tt
+++ b/bin/tt
@@ -1,2 +1,2 @@
 #! /bin/sh
-exec tcptraceroute "$@"
+exec sudo tcptraceroute "$@"
index 2cca0d9cd7168ae93e6241c710ab190897919d7a..bd9d4523323148b90742713ff7a8bb8de045a7bb 100755 (executable)
@@ -1,9 +1,11 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 # https://stackoverflow.com/a/518232/7976758
 
 import sys
 import unicodedata
 
+from m_lib.defenc import default_encoding
+
 
 def strip_accents(s):
     return ''.join(c for c in unicodedata.normalize('NFD', s)
@@ -20,4 +22,7 @@ if __name__ == '__main__':
     if len(sys.argv) == 1:
         sys.exit('Usage: %s name\n' % sys.argv[0])
     for name in sys.argv[1:]:
-        print(latin1_to_ascii(name))
+        sys.stdout.buffer.write(
+            latin1_to_ascii(name).encode(default_encoding, 'surrogateescape')
+            + b'\n'
+        )
index 57af7b1d5a277eec95eb5b9e1e6265c57c98750d..c95cb018477a86966d659dc90851b69e611ff590 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 """Unzip with encoded filenames
 
    Written by Oleg Broytman. Copyright (C) 2009-2024 PhiloSoft Design.
@@ -42,10 +42,15 @@ for zinfo in zf.infolist():
 
     if not tgt.endswith('/'):
         infile = zf.open(zinfo.filename)
-        fp = open(tgt, 'wb')
-        copyfileobj(infile, fp)
-        fp.close()
+        if zinfo.external_attr == 0xA1ED0000:
+            os.symlink(infile.read(), tgt)
+        else:  # regular file
+            fp = open(tgt, 'wb')
+            copyfileobj(infile, fp)
+            fp.close()
         infile.close()
-    dt = time.mktime(zinfo.date_time + (0, 0, -1))
-    os.utime(tgt, (dt, dt))
+    if zinfo.external_attr != 0xA1ED0000:
+        # set timestamp for directories and files but not symlinks
+        dt = time.mktime(zinfo.date_time + (0, 0, -1))
+        os.utime(tgt, (dt, dt))
 zf.close()
diff --git a/bin/vim8 b/bin/vim8
deleted file mode 100755 (executable)
index 63793c0..0000000
--- a/bin/vim8
+++ /dev/null
@@ -1,2 +0,0 @@
-#! /bin/sh
-exec vim -c "ed ++enc=utf-8" "$@"
index a4c20247039990823e979905d90923719477ab0a..c3e941442231d055d9f2155eeb91a31b28a4b9ed 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 import sys, os
 
index e30b6ff26d496d86ac49d8d627653216be927a92..4829e6d445d6673551b14fbd29bb94c393489803 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 from getopt import getopt, GetoptError
 from urllib.parse import urlsplit, parse_qsl, quote, quote_plus, urlencode
@@ -79,7 +79,7 @@ if host:
         url += ':%d' % port
 if path:
     if protocol == "file":
-        url += quote(path)
+        url += quote(path.encode(encoding))
     else:
         if isinstance(path, bytes):
             path = path.decode(default_encoding)
index a851395a6b36aa8d610c146663beea21712ba78c..e9f0c701a5a12aa3937331ea95ca321ae6e190d5 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 
 from getopt import getopt, GetoptError
 from urllib.parse import urlsplit, parse_qsl, quote, quote_plus, urlencode
diff --git a/bin/whereis b/bin/whereis
new file mode 120000 (symlink)
index 0000000..af2e482
--- /dev/null
@@ -0,0 +1 @@
+whence
\ No newline at end of file
index 35bf0e69f00da71c92c80ef55c09767c904e0120..99761a0a29a00370421929578d326ced98d7efbf 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3
+#! /home/phd/.local/bin/python3
 """Zip (zip -r9) with encoded filenames
 
    Written by Oleg Broytman. Copyright (C) 2009-2023 PhiloSoft Design.
@@ -6,7 +6,7 @@
 
 import sys, os
 from getopt import getopt, GetoptError
-from zipfile import ZipFile, ZIP_DEFLATED
+from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED
 from m_lib.defenc import default_encoding
 
 def usage():
@@ -21,13 +21,21 @@ if len(arguments) < 2:
     usage()
 
 def addToZip(zf, path):
-    if os.path.isfile(path):
+    if os.path.isfile(path) or os.path.islink(path):
         print(path)
         if isinstance(path, bytes):
             recoded_path = path.decode(default_encoding).encode('cp866')
         else:
             recoded_path = path
-        zf.write(path, recoded_path, ZIP_DEFLATED)
+        if os.path.islink(path):
+            # http://www.mail-archive.com/python-list@python.org/msg34223.html
+            zipInfo = ZipInfo(recoded_path)
+            zipInfo.create_system = 3
+            # say, symlink attr magic...
+            zipInfo.external_attr = 0xA1ED0000
+            zf.writestr(zipInfo, os.readlink(path))
+        else:
+            zf.write(path, recoded_path, ZIP_DEFLATED)
     elif os.path.isdir(path):
         for nm in os.listdir(path):
             addToZip(zf, os.path.join(path, nm))
index 8931009df9dc9115ea1af0d8db24f423c76c11ac..589b6f64d637a121a81417eaf57bef55904fac8f 100644 (file)
@@ -1,7 +1,10 @@
 !
 ! XTerm
 !
-#if WIDTH > 640
+#if WIDTH > 1900
+! 1920x1080
+# define XTERM_GEOMETRY 80x32
+#elif WIDTH > 1024
 # define XTERM_GEOMETRY 80x30
 #else
 ! 640x480
@@ -378,13 +381,13 @@ Rxvt*color7  : lightgrey
 Rxvt*color15 : white
 
 #if WIDTH > 1600
-# define XFT_FONT xft:Monospace:size=18
+# define XFT_FONT xft:Liberation Mono:size=18
 #elif WIDTH > 1200
-# define XFT_FONT xft:Monospace:size=16
+# define XFT_FONT xft:Liberation Mono:size=16
 #elif WIDTH > 800
-# define XFT_FONT xft:Monospace:size=14
+# define XFT_FONT xft:Liberation Mono:size=14
 #else
-# define XFT_FONT xft:Monospace:size=12
+# define XFT_FONT xft:Liberation Mono:size=12
 #endif
 
 URxvt*termName: rxvt
diff --git a/lib/config/conda b/lib/config/conda
new file mode 100644 (file)
index 0000000..a64d3e1
--- /dev/null
@@ -0,0 +1,37 @@
+_conda_variant=miniforge
+if [ $_conda_variant = miniconda ]; then
+   CONDA_ROOT="$HOME"/miniconda3
+   conda_version=24.9.2-0
+elif [ $_conda_variant = miniforge ]; then
+   CONDA_ROOT="$HOME"/miniforge3
+   conda_version=24.9.0-0
+elif [ $_conda_variant = mambaforge ]; then
+   CONDA_ROOT="$HOME"/mambaforge
+   conda_version=24.9.0-0
+fi
+
+if [ ! -d "$CONDA_ROOT" ]; then
+   if [ $_conda_variant = miniconda ]; then
+       wget -N https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh &&
+       sh ./Miniconda3-latest-Linux-x86_64.sh -b -p "$CONDA_ROOT"
+   elif [ $_conda_variant = miniforge ]; then
+       wget -N https://github.com/conda-forge/miniforge/releases/download/"$conda_version"/Miniforge3-"$conda_version"-Linux-x86_64.sh &&
+       sh ./Miniforge3-"$conda_version"-Linux-x86_64.sh -b -p "$CONDA_ROOT"
+   elif [ $_conda_variant = mambaforge ]; then
+       wget -N https://github.com/conda-forge/miniforge/releases/download/"$conda_version"/Mambaforge-"$conda_version"-Linux-x86_64.sh &&
+       sh ./Mambaforge-"$conda_version"-Linux-x86_64.sh -b -p "$CONDA_ROOT"
+   fi
+fi &&
+
+. "$CONDA_ROOT"/etc/profile.d/conda.sh &&
+
+#if [ ! -f "$CONDA_ROOT"/bin/register-python-argcomplete ]; then
+#eval "$($CONDA_ROOT/bin/register-python-argcomplete conda)" &&
+#fi &&
+
+if [ ! -f "$CONDA_ROOT"/etc/profile.d/bash_completion.sh ]; then
+    conda install --name base --yes conda-bash-completion
+fi &&
+. "$CONDA_ROOT"/etc/profile.d/bash_completion.sh &&
+
+unset _conda_variant CONDA_ROOT conda_version
index 5e79e37732680458589eb39e7576aedf650b8798..f6181d54771298193f83c47a130f8ded118cad3d 100644 (file)
@@ -1,2 +1,4 @@
+#export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
+#unset SSH_AGENT_PID
 gpgconf --launch gpg-agent &&
 include gpg-agent-update-tty
diff --git a/lib/config/hosts b/lib/config/hosts
new file mode 100644 (file)
index 0000000..c2acca1
--- /dev/null
@@ -0,0 +1,5 @@
+0 localhost localhost.localdomain
+0 phdru.name home.phdru.name git.phdru.name zope.phdru.name
+
+# Found in https://blog.sanctum.geek.nz/bash-hostname-completion/
+$include /etc/hosts
index ca338f08f6181c0504dfae0549f85365aea29296..a17ce944ddaa2cdaa183e9fd3196cb8fdd0986b1 100644 (file)
@@ -2,9 +2,4 @@ include git/less
 
 PY_VER=2.7
 export PY_VER
-
-if type -p pip >/dev/null 2>&1; then
-   eval "`pip completion --bash`"
-   rm -rf /tmp/pip_build_"$USER"
-   complete -F _pip_completion pip2 pip2.7 pip3 pip3.3 pip3.4 pip3.5 pip3.6
-fi
+PATH=$PATH:~/prog/git-scripts
diff --git a/lib/config/python3 b/lib/config/python3
new file mode 100644 (file)
index 0000000..4323987
--- /dev/null
@@ -0,0 +1,5 @@
+include git/less
+
+PY_VER=3.7
+export PY_VER
+PATH=$PATH:~/prog/git-scripts
index 1d365c62f9214c649be8f4dc65268a619865457c..4bd52581da2d5f07ee33d8914854f869ffbb078b 100644 (file)
@@ -18,64 +18,61 @@ def init():
 
     # readline/pyreadline
 
-    pyreadlinew32_startup = os.path.join(
-        sys.prefix, 'lib', 'site-packages',
-        'pyreadline', 'configuration', 'startup.py')
+    # From Bruce Edge:
+    # https://mail.python.org/pipermail/python-list/2001-March/062888.html
 
-    if os.path.exists(pyreadlinew32_startup):
-        execfile(pyreadlinew32_startup)
-
-    else:
-        # From Bruce Edge:
-        # https://mail.python.org/pipermail/python-list/2001-March/062888.html
-
-        try:
-            import rlcompleter  # noqa: need for completion
-            import readline
-            initfile = os.environ.get('INPUTRC') \
-                or os.path.expanduser('~/.inputrc')
-            readline.read_init_file(initfile)
-
-            # if 'libedit' in readline.__doc__:
-            #     readline.parse_and_bind("bind ^I rl_complete")
-            # else:
-            #     readline.parse_and_bind("tab: complete")
-
-            histfiles = ['~/.python_history']
-            # if 'VIRTUAL_ENV' in os.environ:
-            #     histfiles.append('$VIRTUAL_ENV/.python_history')
-            for histfile in histfiles:
-                try:
-                    histfile = os.path.expandvars(histfile)
-                    histfile = os.path.expanduser(histfile)
-                    readline.read_history_file(histfile)
-                except IOError:
-                    pass  # No such file
-
-            def savehist():
-                histsize = os.environ.get('HISTSIZE')
-                if histsize:
-                    try:
-                        histsize = int(histsize)
-                    except ValueError:
-                        pass
-                    else:
-                        readline.set_history_length(histsize)
-                histfile = histfiles[-1]
+    try:
+        import rlcompleter  # noqa: need for completion
+        import readline
+        initfile = os.environ.get('INPUTRC') \
+            or os.path.expanduser('~/.inputrc')
+        readline.read_init_file(initfile)
+
+        # if 'libedit' in readline.__doc__:
+        #     readline.parse_and_bind("bind ^I rl_complete")
+        # else:
+        #     readline.parse_and_bind("tab: complete")
+
+        histfiles = ['~/.python_history']
+        # if 'VIRTUAL_ENV' in os.environ:
+        #     histfiles.append('$VIRTUAL_ENV/.python_history')
+        for histfile in histfiles:
+            try:
                 histfile = os.path.expandvars(histfile)
                 histfile = os.path.expanduser(histfile)
+                readline.read_history_file(histfile)
+            except IOError:
+                pass  # No such file
+
+        def savehist():
+            histsize = os.environ.get('HISTSIZE')
+            if histsize:
                 try:
-                    readline.write_history_file(histfile)
-                except IOError:
+                    histsize = int(histsize)
+                except ValueError:
                     pass
-
+                else:
+                    readline.set_history_length(histsize)
+            histfile = histfiles[-1]
+            histfile = os.path.expandvars(histfile)
+            histfile = os.path.expanduser(histfile)
+            try:
+                readline.write_history_file(histfile)
+            except IOError:
+                pass
+
+        import atexit
+        atexit.register(savehist)
+
+        def unset_history():
             import atexit
-            atexit.register(savehist)
+            atexit._exithandlers = []
+        builtins.unset_history = unset_history
 
-        except (ImportError, AttributeError):
-            # no readline or atexit, or readline doesn't have
-            # {read,write}_history_file - ignore the error
-            pass
+    except (ImportError, AttributeError):
+        # no readline or atexit, or readline doesn't have
+        # {read,write}_history_file - ignore the error
+        pass
 
     # terminal