From: Oleg Broytman Date: Fri, 3 May 2024 21:51:57 +0000 (+0300) Subject: Fix(bin/cp_recode_fname): Fix misspelled message X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=commitdiff_plain;h=HEAD;hp=c5883d2a782366c0a3468a989e756cf37dabbd46 Fix(bin/cp_recode_fname): Fix misspelled message --- diff --git a/.bash_completion.d/cgmem_nice b/.bash_completion.d/cgmem_nice index 0b95294..ee553f9 100644 --- a/.bash_completion.d/cgmem_nice +++ b/.bash_completion.d/cgmem_nice @@ -3,10 +3,10 @@ _cgmem_nice() local CUR=${COMP_WORDS[COMP_CWORD]} if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $(compgen -W "100 200 300 500 1000 2000 4000" -- $CUR) ) + COMPREPLY=( $(compgen -W "100 200 300 400 500 1000 2000 4000 5000" -- $CUR) ) elif [ $COMP_CWORD -ge 2 ]; then _command_offset 2 fi } -complete -F _cgmem_nice cgmem_nice +complete -F _cgmem_nice cgmem_nice cgmn diff --git a/.bash_completion.d/git-funcs b/.bash_completion.d/git-funcs new file mode 100644 index 0000000..e41a138 --- /dev/null +++ b/.bash_completion.d/git-funcs @@ -0,0 +1,124 @@ +if test -x /usr/bin/git >/dev/null 2>&1; then + # chdir to a remote's directory (if the remote is on the local FS) + cdremote() { + if [ $# -gt 1 ]; then + echo "Usage: cdremote [remote_name]" >&2 + return 1 + fi + + if [ -z "$1" ]; then + branch="`git rev-parse --abbrev-ref HEAD`" + remote="`git config --get branch.$branch.remote`" + else + remote="$1" + fi + + if [ -n "$remote" ] && git config --get remote.$remote.url | + grep -q '^\(file:/\|/\|\.\./\)'; then # (file:/ or / or ../ at the beginning) + cdgitpath remote.$remote.url + return + fi + + if [ -n "$1" ]; then + echo "Cannot find directory for remote $1" >&2 + echo "Usage: cdremote [remote_name]" >&2 + return 1 + fi + + _list_remotes '^\(file:/\|/\|\.\./\)' # (file:/ or / or ../ at the beginning) + if [ ${#GIT_REMOTES[*]} -eq 1 ]; then + remote=${GIT_REMOTES[0]} + unset GIT_REMOTES + cdgitpath remote.$remote.url + else + unset GIT_REMOTES + echo "Cannot find directory for any remote" >&2 + echo "Usage: cdremote [remote_name]" >&2 + return 1 + fi + } + + # completion for `cd_worktree` + + _cd_worktree_comp() { + local cur="${COMP_WORDS[COMP_CWORD]}" + COMPREPLY=(`compgen -W "$( + git worktree list | awk '{s=$3; gsub("[\\\\[\\\\]]", "", s); print s}' + )" -- "$cur"`) + } + + _cd_worktree_comp_loader() { + _completion_loader git + unset _cd_worktree_comp_loader + complete -F _cd_worktree_comp cd_worktree + return 124 + } + + complete -F _cd_worktree_comp_loader cd_worktree + + # completion for aliases in global .gitconfig + + # fixup rbi rbia rbiap rbip - do refs name completion + _git_fixup() { __gitcomp_nl "$(__git_refs)" ; } + _git_rbi() { __gitcomp_nl "$(__git_refs)" ; } + _git_rbia() { __gitcomp_nl "$(__git_refs)" ; } + _git_rbiap() { __gitcomp_nl "$(__git_refs)" ; } + _git_rbip() { __gitcomp_nl "$(__git_refs)" ; } + # + # push-to-all-remotes - do branch name completion + _git_push_to_all_remotes() { __gitcomp_nl "$(__git_heads)" ; } + + _cdgitpath_complete() { + local cur="${COMP_WORDS[COMP_CWORD]}" + COMPREPLY=(`compgen -W "$(__git_config_get_set_variables)" -- "$cur"`) + } + + _git_open() { + _cdgitpath_complete + } + + complete -F _cdgitpath_complete cdgitpath git-open + + # list remotes with URLs matching a regexp + _list_remotes() { + if [ $# -ne 1 ]; then + echo "Usage: _list_remotes remote_regexp" >&2 + return 1 + fi + declare -ag GIT_REMOTES=() + local remote + for remote in `git remote`; do + if git config --get remote.$remote.url | grep -q "$1"; then + GIT_REMOTES+=($remote) + fi + done + } + + # completion for cdremote and git-open-remote - list remotes with a pattern + _list_remotes_completion() { + local cur="${COMP_WORDS[COMP_CWORD]}" + _list_remotes "$1" + COMPREPLY=(`compgen -W "${GIT_REMOTES[*]}" -- "$cur"`) + unset GIT_REMOTES + } + + # completion for cdremote - list remotes with directories as URLs + _cdremote_complete() { + _list_remotes_completion '^\(file:/\|/\|\.\./\)' # (file:/ or / or ../ at the beginning) + if [ ${#COMPREPLY[*]} -eq 0 ]; then + _list_remotes_completion . + fi + } + + complete -F _cdremote_complete cdremote + + # completion for git-open-remote - list remotes with http(s) URLs + _git_open_remote() { + _list_remotes_completion '^http\(s\)\?://' + if [ ${#COMPREPLY[*]} -eq 0 ]; then + _list_remotes_completion . + fi + } + + complete -F _git_open_remote git-open-remote +fi diff --git a/.bash_completion.d/openvpn b/.bash_completion.d/openvpn new file mode 100644 index 0000000..02d604d --- /dev/null +++ b/.bash_completion.d/openvpn @@ -0,0 +1,5 @@ +# Fix a problem in completion; see https://unix.stackexchange.com/a/529201 + +if [ -r /usr/share/bash-completion/completions/openvpn ]; then + . /usr/share/bash-completion/completions/openvpn +fi diff --git a/.bash_completion.d/python-pip b/.bash_completion.d/python-pip new file mode 100644 index 0000000..f6e3126 --- /dev/null +++ b/.bash_completion.d/python-pip @@ -0,0 +1,14 @@ +PY_VERSIONS="2,2.7,3," +PY_VERSIONS+="$(eval echo 3.{`seq -s, 4 12`} | sed 's/ /,/g')" + +eval delegate_completion python python{$PY_VERSIONS} + +_pip_completion_loader() { + if [ "`type -t _pip_completion`" != function ]; then + eval "`pip3 completion --bash`" + fi + eval complete -F _pip_completion pip pip{$PY_VERSIONS} + unset _pip_completion_loader PY_VERSIONS + return 124 +} +eval complete -F _pip_completion_loader pip pip{$PY_VERSIONS} diff --git a/.bash_prompt b/.bash_prompt deleted file mode 100644 index 6126ef2..0000000 --- a/.bash_prompt +++ /dev/null @@ -1,192 +0,0 @@ -#!/bin/bash - -# bash_prompt; adapted from -# https://github.com/necolas/dotfiles/blob/master/shell/bash_prompt and -# http://vitus-wagner.livejournal.com/1176589.html?thread=40146189#t40146189 - -prompt_git() { - local s="" - local branchName="" - - # check if the current directory is in a git repository - if [ $(git rev-parse --is-inside-work-tree &>/dev/null; printf "%s" $?) == 0 ]; then - - # check if the current directory is in .git before running git checks - if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == "false" ]; then - - # ensure index is up to date - #git update-index --really-refresh -q &>/dev/null - - # check for uncommitted changes in the index - if ! $(git diff --quiet --ignore-submodules --cached); then - s="$s+"; - fi - - # check for unstaged changes - if ! $(git diff-files --quiet --ignore-submodules --); then - s="$s!"; - fi - - # check for untracked files - if [ -n "$(git ls-files --others --exclude-standard)" ]; then - s="$s?"; - fi - - # check for stashed files - if $(git rev-parse --verify refs/stash &>/dev/null); then - s="$s$"; - fi - - fi - - # get the short symbolic ref - # if HEAD isn't a symbolic ref, get the short SHA - # otherwise, just give up - branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ - git rev-parse --short HEAD 2> /dev/null || \ - printf "(unknown)")" - - [ -n "$s" ] && s=" [$s]" - - printf "%s" "$1$branchName$s" - else - return - fi -} - -set_prompts() { - local black="" - local blue="" - local bold="" - local cyan="" - local dim="" - local green="" - local orange="" - local magenta="" - local red="" - local reset="" - local white="" - local yellow="" - - local dim_black="" - local dim_blue="" - local dim_bold="" - local dim_cyan="" - local dim_green="" - local dim_orange="" - local dim_magenta="" - local dim_red="" - local dim_white="" - local dim_yellow="" - - local charStyle="" - local gitStyle="" - local hostStyle="" - local userStyle="" - local wdirStyle="" - - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - tput sgr0 # reset colors - - bold=$(tput bold) - dim=$(tput dim) - reset=$(tput sgr0) - - black=$(tput setaf 0) - blue=$(tput setaf 4) - cyan=$(tput setaf 6) - green=$(tput setaf 2) - orange=$(tput setaf 3) - magenta=$(tput setaf 5) - red=$(tput setaf 1) - white=$bold$(tput setaf 7) - yellow=$(tput setaf 3) - - dim_black=$dim$black - dim_blue=$dim$blue - dim_cyan=$dim$cyan - dim_green=$dim$green - dim_orange=$dim$orange - dim_magenta=$dim$magenta - dim_red=$dim$red - dim_white=$dim$white - dim_yellow=$dim$yellow - else - bold="" - dim="" - reset="\e[0m" - - black="\e[0;30m" - blue="\e[0;34m" - cyan="\e[0;36m" - green="\e[0;32m" - orange="\e[0;33m" - magenta="\e[0;35m" - red="\e[0;31m" - white="\e[0;37m" - yellow="\e[0;33m" - - dim_black="\e[1;30m" - dim_blue="\e[1;34m" - dim_cyan="\e[1;36m" - dim_green="\e[1;32m" - dim_orange="\e[1;33m" - dim_magenta="\e[1;35m" - dim_red="\e[1;31m" - dim_white="\e[1;37m" - dim_yellow="\e[1;33m" - fi - - charStyle="$reset$bold$black" - gitStyle="\[$white\]on \[$magenta\]" - case "$BACKGROUND" in - DARK|dark) - hostStyle="$reset$cyan" - ;; - LIGHT|light) - hostStyle="$reset$blue" - ;; - esac - wdirStyle="$reset$green" - - - # logged in as root - if [[ "$USER" == "root" ]]; then - userStyle="$bold$red" - else - userStyle="$orange" - fi - - # build the prompt - # display the user, host and current working directory in the terminal title - case "$TERM" in - *rxvt*|screen*|*term*|vt100) - PS1="\[\033]0;\u@\h:\w\007\]" - case "$TERM" in - screen*) - PS1+"\[\033k\u@\h:\w\033\\\]" # Set screen/tmux caption - ;; - esac - ;; - - *) - PS1="" - ;; - esac - - #PS1+="\n" # newline - PS1+="\[$userStyle\]\u" # username - PS1+="\[$charStyle\]@" - PS1+="\[$hostStyle\]\h " # host - #PS1+="\[$charStyle\]: " - PS1+="\[$wdirStyle\]\W " # working directory - PS1+='`erco=$?; [ $erco == 0 ] && echo -n ":)" || echo -n '"\"\[$red\]:(\[$reset\] $\""'?=$erco` ' - PS1+="\$(prompt_git \"$gitStyle\")" # git repository details - #PS1+="\n" - PS1+="\[$charStyle\]\$ \[$reset\]" # $ (and reset color) - - export PS1 -} - -set_prompts -unset set_prompts diff --git a/.bashrc b/.bashrc index 867f11d..8c05ad2 100644 --- a/.bashrc +++ b/.bashrc @@ -1,2 +1,213 @@ -if [ "$SHLVL" -eq 1 -a -f "$HOME"/.profile ] ; then . "$HOME"/.profile ; fi -if [ "$SHLVL" -gt 1 -a -f "$HOME"/.shellrc ] ; then . "$HOME"/.shellrc ; fi +# +# $HOME/.bashrc +# + +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# Copied from .profile to do minor initialization for non-interactive non-login-shells +umask 077 + +# Fix default PATH +if [ "$PATH" = "/usr/local/bin:/usr/bin:/bin:/usr/games" ]; then + PATH="$HOME"/bin:"$HOME"/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +fi + +if [ -n "$DISPLAY" ]; then + PATH=$PATH:/usr/games +fi + +# Make `ssh host date` to display in 24-hour format +LANG=C + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return ;; +esac + +# Stop if non-interactive shell +[ -z "$PS1" ] && return + +. "$HOME"/.shellrc + +# This is the default value set by interactive bash +# when the global value was unset. Unset it here too. +if [ "$HISTFILE" = "$HOME/.bash_history" ]; then + history -r + unset HISTFILE +fi + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# append to the history file, don't overwrite it +shopt -s histappend + +[ "`type -t ls`" = alias ] && unalias ls +[ "`type -t ll`" = alias ] && unalias ll + +back() { cd - "$@"; } +functions() { typeset -f "$@"; } +j() { jobs; } + +if [ -r "$HOME"/admin/prog/bash_prompt ]; then + . "$HOME"/admin/prog/bash_prompt + set_prompt + unset set_prompt +else + PS1="${debian_chroot:+($debian_chroot)}\u@\h:\W \$SHLVL\\$ " +fi + +if [ -z "$BASH_COMPLETION_COMPAT_DIR" ]; then + if [ -d /usr/share/bash-completion -a -r /usr/share/bash-completion/bash_completion ]; then + _BASH_COMPLETIONS_DIR=/usr/share/bash-completion/completions + . /usr/share/bash-completion/bash_completion + elif [ -r /etc/bash_completion ]; then + _BASH_COMPLETIONS_DIR=/etc/bash_completion.d + . /etc/bash_completion + elif [ -d /etc/bash_completion.d ] && + [ -n "`ls -A /etc/bash_completion.d`" ]; then + _BASH_COMPLETIONS_DIR=/etc/bash_completion.d + for _compf in /etc/bash_completion.d/*; do + . $_compf + done + elif [ -d /usr/local/etc/bash_completion.d ] && + [ -n "`ls -A /usr/local/etc/bash_completion.d`" ]; then + _BASH_COMPLETIONS_DIR=/usr/local/etc/bash_completion.d + for _compf in /usr/local/etc/bash_completion.d/*; do + . $_compf + done + else + echo "Unknown OS type, cannot source bash_completion" >&2 + fi +fi + +has_completion() { + [ -n "$_BASH_COMPLETIONS_DIR" -a -d "$_BASH_COMPLETIONS_DIR" -a -r "$_BASH_COMPLETIONS_DIR/$1" ] || + complete -p $1 >/dev/null 2>&1 +} + +for cmd in builtin cgmem_nice command dbus-launch exec \ + killall man nice nohup pidof pidOf KillAll pgrep pkill psg pswg \ + run-hosts su sudo time whence whereis which xargs; do + has_completion $cmd || complete -o default -A command $cmd +done + +for cmd in dig host mtr nslookup nc netcat nmap p ping ping6 \ + ssh2 s2 socat telnet t tt \ + tcptraceroute tcptraceroute6 tracert tracert6 traceroute traceroute6 \ + whois wd wget wget-download wget-m wget-wrapper ww; do + has_completion $cmd || complete -A hostname $cmd +done + +for cmd in distribute ftp lftp r rsync \ + s scp ssh smbclient tcpdump tshark wireshark; do + has_completion $cmd || complete -o default -A hostname $cmd +done + +for cmd in bg fg jobs; do + has_completion $cmd || complete -A job $cmd +done + +complete -A job j wait + +for cmd in unset; do + has_completion $cmd || complete -A function -A variable $cmd +done + +delegate_completion() { + local prog programs + prog=$1 + has_completion $prog || return 0 + shift + programs="$@" + eval "_${prog}_completion_loader() { + _completion_loader $prog + if [ x"$DELEGATE_NOSPACE" = x1 ]; then + complete -o nospace -F _$prog $programs + else + complete -F _$prog $programs + fi + unset _${prog}_completion_loader + return 124 + }" + complete -F _${prog}_completion_loader $programs +} + +delegate_completion make m +delegate_completion ping p +DELEGATE_NOSPACE=1 delegate_completion rsync r rsync_cgmn rsync_cgmn_recode rsync_cgmn_recode2 +delegate_completion ssh s +delegate_completion wget wget-m wget-wrapper ww + +if [ -d "$HOME"/.bash_completion.d ] && + [ -n "`ls -A $HOME/.bash_completion.d`" ]; then + for _compf in "$HOME"/.bash_completion.d/*; do + . $_compf + done +fi + +unset _BASH_COMPLETIONS_DIR has_completion delegate_completion + +if [ -d "$HOME/lib/config" ]; then + complete -W "`cd \"$HOME/lib/config\" && echo *`" include +fi +complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser + + +if [ -n "$VIRTUAL_ENV" ] && ! type deactivate >/dev/null 2>&1; then + . "$VIRTUAL_ENV/bin/activate" +fi + +# Clean up python virtual environment on exit +# See https://virtualenvwrapper.readthedocs.io/en/latest/tips.html#clean-up-environments-on-exit + +trap '[ "$VIRTUAL_ENV" ] && deactivate' EXIT + +. virtualenvwrapper_lazy.sh 2>/dev/null + + +if test -d "$HOME"/.pyenv +then + PYENV_ROOT="$HOME"/.pyenv + export PYENV_ROOT + PATH="$PYENV_ROOT/bin:$PATH" + if which pyenv >/dev/null 2>&1; then +# eval "`pyenv init --path`" + eval "`pyenv init -`" + eval "`pyenv virtualenv-init -`" + fi +fi + + +if test -x /usr/bin/screen >/dev/null 2>&1; then + 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 + + copy_function() { + test -n "$(declare -f "$1")" || return + eval "${_/$1/$2}" + } + + rename_function() { + copy_function "$@" || return + unset -f "$1" + } + + rename_function X _non_bash_X + + X() { history -a; _non_bash_X; history -r; } +fi diff --git a/.fvwm/main.m4 b/.fvwm/main.m4 index 22d12e5..8e7c740 100644 --- a/.fvwm/main.m4 +++ b/.fvwm/main.m4 @@ -3,36 +3,23 @@ # dnl The file is in m4 format, use FvwmM4 module to read it -dnl like this: ModuleSynchronous FvwmM4 -lock .fvwm2rc - +dnl like this: ModuleSynchronous FvwmM4 -lock main.m4 +dnl dnl This is to prevent FvwmM4 to shadow $HOME -undefine(`HOME') - +undefine(`HOME')dnl +dnl dnl Echo dimension -`#' width = WIDTH - +`#' width = WIDTH()dnl divert(-1) -dnl koi8-r Fonts -dnl define(`SMALL_FONT_KOI8', `-*-fixed-medium-r-normal-*-*-100-*-*-*-*-koi8-r') -dnl define(`MEDIUM_FONT_KOI8', `-*-fixed-medium-r-normal-*-*-120-*-*-*-*-koi8-r') -dnl define(`BIG_FONT_KOI8', `-*-fixed-medium-r-normal-*-*-140-*-*-*-*-koi8-r') - -dnl cp1251 Fonts -dnl define(`SMALL_FONT_CP1251', `-*-fixed-medium-r-normal-*-*-100-*-*-*-*-*-cp1251') -dnl define(`MEDIUM_FONT_CP1251', `-*-fixed-medium-r-normal-*-*-120-*-*-*-*-*-cp1251') -dnl define(`BIG_FONT_CP1251', `-*-fixed-medium-r-normal-*-*-140-*-*-*-*-*-cp1251') - -dnl define(`XBUFFY_FONT', `-cronyx-helvetica-bold-r-*-*-*-100-*-*-*-*-koi8-r') - dnl TrueType Fonts -define(`VERY_SMALL_FONT', `xft:Sans:size=10') -define(`SMALL_FONT', `xft:Sans:size=12') -define(`MEDIUM_FONT', `xft:Sans:size=14') -define(`BIG_FONT', `xft:Sans:size=16') -define(`LARGE_FONT', `xft:Sans:size=18') -define(`HUGE_FONT', `xft:Sans:size=20') -define(`GIGANTIC_FONT', `xft:Sans:size=22') +define(`VERY_SMALL_FONT', `"xft:Liberation Mono:size=10"') +define(`SMALL_FONT', `"xft:Liberation Mono:size=12"') +define(`MEDIUM_FONT', `"xft:Liberation Mono:size=14"') +define(`BIG_FONT', `"xft:Liberation Mono:size=16"') +define(`LARGE_FONT', `"xft:Liberation Mono:size=18"') +define(`HUGE_FONT', `"xft:Liberation Mono:size=20"') +define(`GIGANTIC_FONT', `"xft:Liberation Mono:size=22"') dnl Bold TT fonts define(`SMALL_BOLD_FONT', SMALL_FONT`:Bold') @@ -80,65 +67,122 @@ define(`TERM_GEOM_BOTRT', TERM_GEOM`-0-0') define(`TERM_GEOM_BIG', ifelse(eval(WIDTH < 1024), 1, `96x30', - eval(WIDTH < 1920), 1, `112x32+2-0', `126x35')) + eval(WIDTH < 1920), 1, `112x32+2-0', `127x32+1-0')) define(`TERM', `urxvt') define(`TERM_KOI8', `Exec LC_CTYPE=ru_RU.KOI8-R exec TERM') -define(`TERM_UTF8', `Exec exec "$HOME"/lib/X11/utf8rxvt') +define(`TERM_RU_UTF8', `Exec LC_CTYPE=ru_RU.UTF-8 exec TERM -name URxvt') +define(`TERM_EN_UTF8', `Exec LC_CTYPE=en_US.UTF-8 exec TERM -name URxvt') +define(`TERM_HEB_UTF8', `Exec LC_CTYPE=he_IL.UTF-8 exec TERM -name URxvt') define(`TERM_KOI8_BOTLT', `TERM_KOI8 -geometry TERM_GEOM_BOTLT') -define(`TERM_UTF8_BOTLT', `TERM_UTF8 -geometry TERM_GEOM_BOTLT') +define(`TERM_RU_UTF8_BOTLT', `TERM_RU_UTF8 -geometry TERM_GEOM_BOTLT') define(`TERM_KOI8_BOTRT', `TERM_KOI8 -geometry TERM_GEOM_BOTRT') -define(`TERM_UTF8_BOTRT', `TERM_UTF8 -geometry TERM_GEOM_BOTRT') +define(`TERM_RU_UTF8_BOTRT', `TERM_RU_UTF8 -geometry TERM_GEOM_BOTRT') +define(`TERM_KOI8_BIG', `TERM_KOI8 -geometry TERM_GEOM_BIG') +define(`TERM_UTF8_BIG', `TERM_RU_UTF8 -geometry TERM_GEOM_BIG') + + +define(`SSH', `cgmem_nice 300 ssh') + +define(`TERM_SSH', `$1 -e SSH $2') + +define(`TERM_TITLE_SSH', `$1 -title "$3" -n "$3" -e SSH $2') + +define(`TERM_KOI8_SSH', +`TERM_TITLE_SSH(`TERM_KOI8', $1, $2)') + +define(`SSH_SCREEN_KOI8', +`SSH -t $1 TZ="$(cat /etc/timezone)" exec /usr/bin/screen -xRR -S default-koi8') +define(`SSH_SCREEN_UTF8', +`SSH -t $1 TZ="$(cat /etc/timezone)" exec /usr/bin/screen -xRR -S default-utf8') + +define(`TERM_TITLE_SSH_SCREEN_KOI8', +`$1 -title "$3 scr" -n "$3 scr" -e SSH_SCREEN_KOI8($2)') + +define(`TERM_TITLE_SSH_SCREEN_UTF8', +`$1 -title "$3 scr" -n "$3 scr" -e SSH_SCREEN_UTF8($2)') + +define(`MENU_TERM_KOI8_SSH', +`"$2 (koi8)" TERM_KOI8_SSH($1, $2)') + +define(`TERM_KOI8_BOTLT_SSH', +`TERM_TITLE_SSH(`TERM_KOI8_BOTLT', $1, $2)') + +define(`TERM_KOI8_BOTRT_SSH', +`TERM_TITLE_SSH(`TERM_KOI8_BOTRT', $1, $2)') + +define(`MENU_TERM_KOI8_BOTLT_SSH', +`"$2 (btlt,koi8)" TERM_KOI8_BOTLT_SSH($1, $2)') + +define(`MENU_TERM_KOI8_BOTRT_SSH', +`"$2 (btrt,koi8)" TERM_KOI8_BOTRT_SSH($1, $2)') + +define(`TERM_KOI8_SSH_SCREEN', +`TERM_TITLE_SSH_SCREEN_KOI8(`TERM_KOI8', $1, $2)') + +define(`MENU_TERM_KOI8_SSH_SCREEN', +`"$2 (koi8,scr)" TERM_TITLE_SSH_SCREEN_KOI8(`TERM_KOI8', $1, $2)') + +define(`TERM_KOI8_BOTLT_SSH_SCREEN', +`TERM_TITLE_SSH_SCREEN_KOI8(`TERM_KOI8_BOTLT', $1, $2)') +define(`TERM_KOI8_BOTRT_SSH_SCREEN', +`TERM_TITLE_SSH_SCREEN_KOI8(`TERM_KOI8_BOTRT', $1, $2)') -define(`REMOTE_HOST_TERM', -`$1 -e ssh -4 $2') +define(`MENU_TERM_KOI8_BOTLT_SSH_SCREEN', +`"$2 (btlt,koi8,scr)" TERM_KOI8_BOTLT_SSH_SCREEN($1, $2)') -define(`REMOTE_HOST_TERM_TITLE', -`$1 -title $3 -n $3 -e ssh -4 $2') +define(`MENU_TERM_KOI8_BOTRT_SSH_SCREEN', +`"$2 (btrt,koi8,scr)" TERM_KOI8_BOTRT_SSH_SCREEN($1, $2)') -define(`REMOTE_HOST_KOI8', -REMOTE_HOST_TERM_TITLE(TERM_KOI8, $1, $2)) +define(`TERM_UTF8_SSH', +`TERM_TITLE_SSH(`TERM_RU_UTF8', $1, $2)') -define(`REMOTE_HOST_KOI8_MENU', -"$2 (koi8)" REMOTE_HOST_KOI8($1, $2)) +define(`MENU_TERM_UTF8_SSH', +`"$2 (utf8)" TERM_UTF8_SSH($1, $2)') -define(`REMOTE_HOST_KOI8_BOTLT', -REMOTE_HOST_TERM_TITLE(TERM_KOI8_BOTLT, $1, $2)) +define(`TERM_UTF8_BOTLT_SSH', +`TERM_TITLE_SSH(`TERM_RU_UTF8_BOTLT', $1, $2)') -define(`REMOTE_HOST_KOI8_BOTRT', -REMOTE_HOST_TERM_TITLE(TERM_KOI8_BOTRT, $1, $2)) +define(`TERM_UTF8_BOTRT_SSH', +`TERM_TITLE_SSH(`TERM_RU_UTF8_BOTRT', $1, $2)') -define(`REMOTE_HOST_KOI8_BOTLT_MENU', -"$2 (koi8,btlt)" REMOTE_HOST_KOI8_BOTLT($1, $2)) +define(`MENU_TERM_UTF8_BOTLT_SSH', +`"$2 (btlt,utf8)" TERM_UTF8_BOTLT_SSH($1, $2)') -define(`REMOTE_HOST_KOI8_BOTRT_MENU', -"$2 (koi8,btrt)" REMOTE_HOST_KOI8_BOTRT($1, $2)) +define(`MENU_TERM_UTF8_BOTRT_SSH', +`"$2 (btrt,utf8)" TERM_UTF8_BOTRT_SSH($1, $2)') -define(`REMOTE_HOST_UTF8', -REMOTE_HOST_TERM(TERM_UTF8, $1)) +define(`TERM_UTF8_SSH_SCREEN', +`TERM_TITLE_SSH_SCREEN_UTF8(`TERM_RU_UTF8', $1, $2)') -define(`REMOTE_HOST_UTF8_MENU', -"$2 (utf8)" REMOTE_HOST_UTF8($1, $2)) +define(`MENU_TERM_UTF8_SSH_SCREEN', +`"$2 (utf8,scr)" TERM_UTF8_SSH_SCREEN($1, $2)') -define(`REMOTE_HOST_UTF8_BOTLT', -REMOTE_HOST_TERM(TERM_UTF8_BOTLT, $1)) +define(`TERM_UTF8_BOTLT_SSH_SCREEN', +`TERM_TITLE_SSH_SCREEN_UTF8(`TERM_RU_UTF8_BOTLT', $1, $2)') -define(`REMOTE_HOST_UTF8_BOTRT', -REMOTE_HOST_TERM(TERM_UTF8_BOTRT, $1)) +define(`TERM_UTF8_BOTRT_SSH_SCREEN', +`TERM_TITLE_SSH_SCREEN_UTF8(`TERM_RU_UTF8_BOTRT', $1, $2)') -define(`REMOTE_HOST_UTF8_BOTLT_MENU', -"$2 (utf8,btlt)" REMOTE_HOST_UTF8_BOTLT($1, $2)) +define(`MENU_TERM_UTF8_BOTLT_SSH_SCREEN', +`"$2 (btlt,utf8,scr)" TERM_UTF8_BOTLT_SSH_SCREEN($1, $2)') -define(`REMOTE_HOST_UTF8_BOTRT_MENU', -"$2 (utf8,btrt)" REMOTE_HOST_UTF8_BOTRT($1, $2)) +define(`MENU_TERM_UTF8_BOTRT_SSH_SCREEN', +`"$2 (btrt,utf8,scr)" TERM_UTF8_BOTRT_SSH_SCREEN($1, $2)') -define(`REMOTE_HOST_KOI8_BIG', -TERM_KOI8 -geometry TERM_GEOM_BIG -title "$2" -n "$2" -e ssh -4 "$1") +define(`TERM_KOI8_BIG_SSH', +`TERM_KOI8_BIG -title "$2" -n "$2" -e SSH "$1"') -define(`REMOTE_HOST_KOI8_BIG_MENU', -"$2 (koi8)" REMOTE_HOST_KOI8_BIG($1, $2)) +define(`MENU_TERM_KOI8_BIG_SSH', +`"$2 (koi8)" TERM_KOI8_BIG_SSH($1, $2)') + +define(`TERM_KOI8_BIG_SSH_SCREEN', +`TERM_KOI8_BIG -title "$2" -n "$2" -e SSH_SCREEN_KOI8 "$1"') + +define(`MENU_TERM_KOI8_BIG_SSH_SCREEN', +`"$2 (koi8,scr)" TERM_KOI8_BIG_SSH_SCREEN($1, $2)') divert @@ -147,7 +191,7 @@ divert # # Colon seperated unix directory paths for Modules, xpm files, and bitmaps #ModulePath /usr/lib/fvwm -ImagePath /usr/share/pixmaps/fvwm:/usr/share/pixmaps:/usr/include/X11/bitmaps #:/usr/local/firefox/browser/chrome/icons/default:/usr/local/firefox/browser/icons +ImagePath /usr/share/icons/hicolor/32x32/apps/:/usr/share/pixmaps/fvwm:/usr/share/pixmaps:/usr/include/X11/bitmaps #:/usr/local/firefox/browser/chrome/icons/default:/usr/local/firefox/browser/icons ############################################################################ # COLORS and FONTS @@ -246,10 +290,6 @@ Style "FvwmPager" Layer 2 # Terminals Style "*term" Icon term.xpm Style "*rxvt" Icon term.xpm -Style "term-im-local" Icon pidgin-menu.xpm -Style "term-im-remote" Icon rcalc2.xpm -Style "term-im-*" IconBox 630 -75 -2 -2, IconGrid 200 80 -Style "term-im-*" StartsOnPage 1 1 0, StartIconic # Browsers' windows Style "Certificate Manager" PositionPlacement Center @@ -258,19 +298,11 @@ Style "*Mozilla*" PositionPlacement +0 -0 Style "*Chromium*" PositionPlacement +0 -0 -# IM -Style "Gajim" PositionPlacement +0 -0 -Style "* - Gajim" MinOverlapPercentPlacement -# Pidgin -Style "Buddy List" PositionPlacement +0 -0 -Style "*Pidgin*" MinOverlapPercentPlacement - -# (S)MPlayer -Style "*MPlayer*" Layer 6, PositionPlacement 250p 100p -Style "*mpv" Layer 6, PositionPlacement 250p 100p +# Video player(s) +Style "*mpv" Layer 6, PositionPlacement 200p 150p Style "*clock" !Title, Sticky, WindowListSkip, Color Black/#40c040, NeverFocus, PositionPlacement 50-50w +1p, Layer 2 -Style "emacs" NoPPosition +Style "deadbeef" PositionPlacement -0 -0 Style "gxmessage" PositionPlacement 50-50w +20 Style "*lock" !Title, Sticky, WindowListSkip Style "Mosaic" NoPPosition @@ -473,7 +505,7 @@ AddToFunc RestartFunction DestroyFunc UrgencyFunc AddToFunc UrgencyFunc + I Iconify off -+ I ThisWindow ("*Downloads") Break ++ I ThisWindow ("*Downloads|Skype") Break 1 + I FlipFocus + I Raise + I WarpToWindow 5p 5p @@ -483,43 +515,29 @@ AddToFunc StartStandardSession + I GotoDeskAndPage 0 0 0 + I TERM_KOI8 + I Wait TERM -+ I GotoDeskAndPage 0 0 1 -+ I TERM_UTF8 -geometry 38x30+0-0 -+ I Wait URxvt -+ I GotoDeskAndPage 0 1 0 -+ I TERM_KOI8 -e su - -+ I Wait TERM ++ I Exec exec cgmem_nice 200 pulseaudio --start + I PaVuControl + I Exec exec "$HOME"/current/projects/audio-cdr-video/audio/pa-mic-off + I XsetbgFilename + I Wait gxmessage -+ I GotoDeskAndPage 1 0 1 -+ I TERM_KOI8 -+ I Wait TERM -+ I GotoDeskAndPage 1 1 0 -#+ I TERM_UTF8 -iconic -name term-im-remote -#+ I Wait term-im-remote -+ I TERM_KOI8 -geometry 60x25-5-5 -iconic -name term-im-local -+ I Wait term-im-local + I GotoDeskAndPage 2 0 1 -+ I TERM_KOI8 -geometry TERM_GEOM_BIG ++ I TERM_KOI8_BIG + I Wait TERM + I FireFox -+ I Schedule 4500 GotoDeskAndPage 0 1 0 DestroyFunc ResumeFunction AddToFunc ResumeFunction + I GotoDeskAndPage 0 0 0 + I TERM_KOI8 + I Wait TERM ++ I Exec exec cgmem_nice 200 pulseaudio --start + I None ("Volume Control") PaVuControl + I Exec sleep 10; exec "$HOME"/current/projects/audio-cdr-video/audio/pa-mic-off + I XsetbgFilename + I Wait gxmessage -+ I Any ("*Mozilla Firefox") GotoDeskAndPage 0 1 0 -+ I TestRc (Match) Break ++ I Any ("*Mozilla Firefox") GotoDeskAndPage 0 1 1 ++ I TestRc (Match) Break 1 + I None ("*Mozilla Firefox") FireFox -+ I Schedule 4500 GotoDeskAndPage 0 1 0 ############################################################################ # COMPLEX FUNCTIONS @@ -589,42 +607,55 @@ AddToFunc Raise-All I All Raise DestroyFunc PaVuControl AddToFunc PaVuControl I GotoDeskAndPage 0 1 1 -+ I Exec exec pavucontrol ++ I Exec exec pulseaudio --kill ++ I Exec exec cgmem_nice 200 pulseaudio --start ++ I Exec exec cgmem_nice 200 pavucontrol + I Wait "Volume Control" -changequote([,]) DestroyFunc Id3Info -AddToFunc Id3Info I Exec "$HOME"/lib/audio/mp3/id3info.py "`deadbeef --nowplaying '%F'`" | text-wrap.py | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file - -changequote([`], [']) - -DestroyFunc DeadBeef -AddToFunc DeadBeef I GotoDeskAndPage 0 1 1 -+ I Exec exec deadbeef - -DestroyFunc Term-Phdru -AddToFunc Term-Phdru I GotoDeskAndPage 1 0 1 -+ I REMOTE_HOST_KOI8(phdru.name, phdru.name) - -DestroyFunc Term-Phdru-Big -AddToFunc Term-Phdru-Big I GotoDeskAndPage 1 0 1 -+ I REMOTE_HOST_KOI8_BIG(phdru.name, phdru.name) +AddToFunc Id3Info I Exec "$HOME"/lib/audio/mp3/id3info.py "$(audtool --current-song-filename)" | text-wrap.py | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file - + +DestroyFunc Term2HostsHome +AddToFunc Term2HostsHome I GotoDeskAndPage 1 1 2 ++ I PipeRead 'test -n "$(ip address show tun0 up 2>/dev/null)" || test -n "$(ip address show wg0 up 2>/dev/null)" || { echo Exec exec gxmessage -buttons Ok -default Ok "ERROR: Cannot find tun0/wg0 interfaces!"; echo Wait gxmessage; echo Break 1; }' ++ 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 Wait TERM ++ I GotoDeskAndPage 1 1 2 DestroyFunc FireFox -AddToFunc FireFox I Any ("*Mozilla Firefox") Break +AddToFunc FireFox I Any ("*Mozilla Firefox") Break 1 + I GotoDeskAndPage 1 0 0 -+ I Exec exec start-browser firefox -+ I Wait "*Mozilla Firefox" -+ I All ("*Mozilla Firefox") Iconify true -+ I Exec webbrowserX -n file:///home/phd/Internet/WWW/dashboard/index.html ++ I Exec LC_CTYPE=ru_RU.KOI8-R exec cgmem_nice 4000 start-browser firefox -P phd + I Wait "*Mozilla Firefox" +DestroyFunc SuspendFireFox +AddToFunc SuspendFireFox I Exec exec pkill -STOP firefox ++ I All ("*Mozilla Firefox") Iconify True + +DestroyFunc ResumeFireFox +AddToFunc ResumeFireFox I Exec exec pkill -CONT firefox ++ I All ("*Mozilla Firefox") Iconify False + +DestroyFunc Chromium +AddToFunc Chromium I Any ("*Chromium") Break 1 ++ I GotoDeskAndPage 1 1 0 ++ I Exec LC_CTYPE=ru_RU.KOI8-R exec cgmem_nice 2000 start-browser chromium ++ I Wait "*Chromium" + DestroyFunc Gajim AddToFunc Gajim I GotoDeskAndPage 1 1 0 -+ I Exec exec gajim ++ I Exec exec cgmem_nice 300 gajim DestroyFunc Pidgin AddToFunc Pidgin I GotoDeskAndPage 1 1 0 -+ I Exec exec pidgin ++ 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 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 - @@ -671,16 +702,17 @@ AddToMenu Window-Ops2 "Center" Center AddToMenu Terminals "Terminals" Title + "Grey term (koi8)" TERM_KOI8 -+ "Grey term (utf8)" TERM_UTF8 -+ "Grey term (koi8,btlt)" TERM_KOI8_BOTLT -+ "Grey term (koi8,btrt)" TERM_KOI8_BOTRT -+ "Grey term (utf8,btlt)" TERM_UTF8_BOTLT -+ "Grey term (utf8,btrt)" TERM_UTF8_BOTRT -+ "Big grey term (koi8)" TERM_KOI8 -geometry TERM_GEOM_BIG -+ "Big grey term (utf8)" TERM_UTF8 -geometry TERM_GEOM_BIG ++ "Grey term (utf8)" TERM_RU_UTF8 ++ "Grey term (heb-utf8)" TERM_HEB_UTF8 ++ "Grey term (btlt,koi8)" TERM_KOI8_BOTLT ++ "Grey term (btrt,koi8)" TERM_KOI8_BOTRT ++ "Grey term (btlt,utf8)" TERM_RU_UTF8_BOTLT ++ "Grey term (btrt,utf8)" TERM_RU_UTF8_BOTRT ++ "Big grey term (koi8)" TERM_KOI8_BIG ++ "Big grey term (utf8)" TERM_UTF8_BIG + "" Nop + "White/black term (koi8)" TERM_KOI8 -fg white -cr white -bg black -+ "White/black term (utf8)" TERM_UTF8 -fg white -bg black ++ "White/black term (utf8)" TERM_RU_UTF8 -fg white -bg black AddToMenu TermColors "Term Colors" Title + "Term: black/mediumturquoise" TERM_KOI8 -fg black -cr black -bg mediumturquoise @@ -708,15 +740,25 @@ AddToMenu TermColors "Term Colors" Title + "Term: white/black" TERM_KOI8 -fg white -cr white -bg black AddToMenu Systems "Systems" Title -+ REMOTE_HOST_KOI8_MENU(phdru.name, phdru) -+ REMOTE_HOST_UTF8_BOTLT_MENU(phdru.name, phdru) -+ REMOTE_HOST_KOI8_BIG_MENU(phdru.name, PHDRU) ++ "Iskra+Phdru" Term2HostsHome ++ "" Nop +pushdef(`TERM_KOI8', `Exec LC_CTYPE=ru_RU.KOI8-R exec TERM -xrm "*Page: 1 1 1"')dnl +pushdef(`TERM_RU_UTF8', `Exec LC_CTYPE=ru_RU.UTF-8 exec TERM -name URxvt -xrm "*Page: 1 1 1"')dnl ++ MENU_TERM_KOI8_SSH_SCREEN(iskra-aviel.phdru.name, iskra) ++ MENU_TERM_UTF8_BOTLT_SSH(iskra-aviel.phdru.name, iskra) ++ MENU_TERM_KOI8_BIG_SSH(iskra-aviel.phdru.name, ISKRA) ++ "" Nop +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_UTF8_BOTLT_SSH(phdru.name, phdru) ++ MENU_TERM_KOI8_BIG_SSH(phdru.name, PHDRU) +popdef(`TERM_KOI8', `TERM_RU_UTF8')dnl AddToMenu FvwmCommands "Fvwm Commands" Title + "Restart" Restart + "Raise all" Raise-All -#+ "Restart Fvwm2" Restart fvwm2 -#+ "Start Fvwm" Restart fvwm + "Fvwm Setup" Popup FvwmSetup + "Fvwm Modules" Popup FvwmModules + "" Nop @@ -781,42 +823,33 @@ AddToMenu RootMenu "Root Menu" Title + "XSetBg" Popup XSetBgMenu + "Fvwm Commands" Popup FvwmCommands +DestroyMenu OSMenu +AddToMenu OSMenu "OS commands:" Title ++ "Suspend to both" Exec exec s2b ++ "Suspend to disk" Exec exec s2d ++ "Suspend to ram" Exec exec s2r + # This menu will fire up some often used programs -DestroyMenu Utilities +DestroyMenu Utilities AddToMenu Utilities "Choose one:" Title -+ "qPDFview" Exec exec qpdfview -+ "FBReader" Exec exec fbreader -+ "" Nop -+ "GVim" Exec exec gvim ++ "OS" Popup OSMenu + "" Nop -#+ "XFortune" Exec /usr/games/fortune | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file - -#+ "xbuffy" Exec exec xbuffy -fn 'XBUFFY_FONT' -geometry +0+125 -boxfile mail/misc/.xbuffyrc -#+ "" Nop -+ "pavucontrol" PaVuControl -+ "DeadBeef" DeadBeef -+ "Id3Info" Id3Info -+ "" Nop -+ "Gajim" Gajim -+ "Pidgin" Pidgin -+ "" Nop -+ "xload" Exec exec xload -geometry =136x136+0+0 -+ "Top" TERM_KOI8 -T Top -n Top -e top ++ "GVim (koi8)" Exec LC_CTYPE=ru_RU.KOI8-R exec gvim ++ "GVim (utf8)" Exec LC_CTYPE=ru_RU.UTF-8 exec gvim + "" Nop + "Refresh Screen" Refresh + "xrefresh" Exec exec xrefresh + "" Nop -#+ "xcalc" Exec exec xcalc -+ "xclipboard" Exec exec xclipboard -+ "xcutsel" Exec exec xcutsel -#+ "xman" Exec exec xman -notopbox -geometry +150+102 -#+ "emacs" Exec emacs -geometry 81x35+150+34 -#+ "xv" Function warp-or-run xv "Exec exec xv -ncols 240 -geometry +0+0" ++ "Skype" Skype ++ "pavucontrol" PaVuControl DestroyMenu Browsers AddToMenu Browsers "Choose one:" Title + "FireFox" FireFox -+ "Chromium" None ("*Chromium") Exec exec start-browser chromium -+ "Opera" None ("*Opera") Exec exec start-browser opera ++ "Suspend FireFox" SuspendFireFox ++ "Resume FireFox" ResumeFireFox ++ "" Nop ++ "Chromium" Chromium # A wide variety of screenlocking options... #AddToMenu XlockMenu "Choose one:" Title @@ -833,33 +866,34 @@ AddToMenu Browsers "Choose one:" Title #+ "Blank" Exec exec xlock -mode blank AddToMenu XScreenSaverMenu "Choose mode:" Title -+ "Blank Screen Now" Exec exec xscreensaver-command -activate -+ "Lock Screen Now" Exec exec xscreensaver-command -lock -+ "Screen Saver Demo" Exec exec xscreensaver-command -demo -+ "Screen Saver Preferences" Exec exec xscreensaver-command -prefs -+ "Reinitialize Screen Saver" Exec exec xscreensaver-command -restart ++ "Blank Screen via xset" Exec xset dpms force off +#+ "Blank Screen Now" Exec exec xscreensaver-command --suspend ++ "Activate A Hack Now" Exec exec xscreensaver-command --activate ++ "Lock Screen Now" Exec exec xscreensaver-command --lock ++ "" Nop ++ "Screen Saver Demo" Exec exec xscreensaver-demo ++ "Screen Saver Settings" Exec exec xscreensaver-settings + "" Nop -+ "Kill Screen Saver" Exec exec xscreensaver-command -exit ++ "Kill Screen Saver" Exec exec xscreensaver-command --exit + "Launch Screen Saver" Exec exec xscreensaver ++ "Reinitialize Screen Saver" Exec exec xscreensaver-command --restart AddToMenu XSetBgMenu "XSetBg" Title + "Change wallpaper" Exec exec "$HOME"/current/projects/xsetbg/xsetbg-force -+ "Start" Exec exec "$HOME"/current/projects/xsetbg/xsetbg-http-start ++ "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 -changequote([,]) -+ "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" -+ "Open in browser" Exec exec webbrowserX -n "`$HOME/current/projects/xsetbg/print-filename.py -e koi8-r`" ++ "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" ++ "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" -+ "Open in browser (prev.)" Exec exec webbrowserX -n "`$HOME/current/projects/xsetbg/print-filename.py -e koi8-r 1`" -changequote([`], [']) ++ "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" ++ "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 - @@ -901,19 +935,25 @@ changequote([`], [']) #*FvwmButtons: (Swallow XClock 'Exec exec xclock -update 1 -geometry -3000-3000') # Buttons -pushdef(`TERM_KOI8', `Exec "TERM" LC_CTYPE=ru_RU.KOI8-R exec TERM') -pushdef(`TERM_UTF8', `Exec "URxvt" exec "$HOME"/lib/X11/utf8rxvt') +pushdef(`TERM_KOI8', `Exec "TERM" LC_CTYPE=ru_RU.KOI8-R exec TERM')dnl +pushdef(`TERM_RU_UTF8', `Exec "URxvt" LC_CTYPE=ru_RU.UTF-8 exec TERM -name URxvt')dnl *FvwmButtons: (Title Term, Icon rterm2.xpm, Action TERM_KOI8) -*FvwmButtons: (Title UTF-8, Icon rterm2.xpm, Action TERM_UTF8) -*FvwmButtons: (Title phdru, Icon xterm-sgi.xpm, Action REMOTE_HOST_KOI8(phdru.name, phdru.name)) -popdef(`TERM_KOI8', `TERM_UTF8') +*FvwmButtons: (Title UTF-8, Icon rterm2.xpm, Action TERM_RU_UTF8) +popdef(`TERM_KOI8', `TERM_RU_UTF8')dnl +pushdef(`TERM_KOI8', `Exec "TERM" LC_CTYPE=ru_RU.KOI8-R exec TERM -xrm "*Page: 1 0 1"')dnl +*FvwmButtons: (Title "phdru (k8,s)", Icon xterm-sgi.xpm, Action TERM_KOI8_SSH_SCREEN(phdru.name, phdru.name)) +popdef(`TERM_KOI8')dnl +pushdef(`TERM_KOI8', `Exec "TERM" LC_CTYPE=ru_RU.KOI8-R exec TERM -xrm "*Page: 1 1 1"')dnl +*FvwmButtons: (Title "iskra (k8,s)", Icon xterm-sgi.xpm, Action TERM_KOI8_SSH_SCREEN(iskra-aviel.phdru.name, iskra)) +popdef(`TERM_KOI8')dnl *FvwmButtons: (Title Wallpaper, Icon find1.xpm, Action Exec "gxmessage" "$HOME"/current/projects/xsetbg/print-filename.py | text-wrap.py -w TEXT_WIDTH -s | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file -) *FvwmButtons: (Title "-1", Icon find1.xpm, Action Exec "gxmessage" "$HOME"/current/projects/xsetbg/print-filename.py 1 | text-wrap.py -w TEXT_WIDTH -s | gxmessage -buttons Ok -default Ok -fn 'MESSAGE_FONT' -file -) *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 pavucontrol) +#*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 DeadBeef, Icon bell.xpm, Action Exec "DeaDBeeF-*" exec deadbeef) +#*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) ############################################################################ @@ -942,7 +982,7 @@ popdef(`TERM_KOI8', `TERM_UTF8') #*Rlogin: Input UserName 10 "" #*Rlogin: Line expand #*Rlogin: Button quit "Login" ^M -#*Rlogin: Command TERM_KOI8 -T term@$(HostName) -e rlogin $(HostName) $(Custom?-l $(UserName)) +`#'*Rlogin: Command TERM_KOI8 -T term@$(HostName) -e rlogin $(HostName) $(Custom?-l $(UserName)) #*Rlogin: Button restart "Clear" #*Rlogin: Command Beep #*Rlogin: Button quit "Cancel" diff --git a/.gitconfig b/.gitconfig index b91ec8d..e38baa0 100644 --- a/.gitconfig +++ b/.gitconfig @@ -178,7 +178,12 @@ sw = show --word-diff --decorate unstage = reset HEAD -- - pr = "!f() { git fetch ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f" + # Github: pull request, Gitlab: merge request + mpr = "!f() { git fetch ${2:-origin} refs/$3/$1/head:pr/$1 && if [ \"$4\" = checkout ]; then git checkout pr/$1; fi; }; f" + fetch-mr = "!f() { git mpr $1 ${2:-origin} merge-requests; }; f" + merge-request = "!f() { git mpr $1 ${2:-origin} merge-requests checkout; }; f" + fetch-pr = "!f() { git mpr $1 ${2:-origin} pull; }; f" + pull-request = "!f() { git mpr $1 ${2:-origin} pull checkout; }; f" clean-pr = "!git checkout master ; git for-each-ref refs/heads/pr/* --format=\"%(refname)\" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done" [branch] @@ -196,6 +201,9 @@ [include] path = ~/lib/config/git/light_bg +[init] + defaultBranch = master + [log] abbrevCommit = true #mailmap = true @@ -222,6 +230,11 @@ #[tag] # sort = version:refname +[tar "tar.bz2"] + command = bzip2 -c +[tar "tar.xz"] + command = xz -c + #[transfer] # fsckObjects = true @@ -238,12 +251,37 @@ fontui = -family \"DejaVu Sans\" -size 18 -weight normal -slant roman -underline 0 -overstrike 0 fontdiff = -family \"DejaVu Sans Mono\" -size 18 -weight normal -slant roman -underline 0 -overstrike 0 -# Github URL shortcuts -[url "git@github.com:"] - insteadOf = "gh:" - insteadOf = "github:" - insteadOf = "git://github.com/" -[url "git@gist.github.com:"] - insteadOf = "gst:" - insteadOf = "gist:" - insteadOf = "git://gist.github.com/" +# git:// protocol fixers +#[url "https://github.com/"] +# insteadOf = "git://github.com/" +#[url "https://gist.github.com/"] +# insteadOf = "git://gist.github.com/" +#[url "ssh://git@github.com/"] +# insteadOf = "git://github.com/" +#[url "ssh://git@gist.github.com/"] +# insteadOf = "git://gist.github.com/" +#[url "https://gitlab.com/"] +# insteadOf = "git://gitlab.com/" +#[url "https://gist.gitlab.com/"] +# insteadOf = "git://gist.gitlab.com/" +#[url "ssh://git@gitlab.com/"] +# insteadOf = "git://gitlab.com/" +#[url "ssh://git@gist.gitlab.com/"] +# insteadOf = "git://gist.gitlab.com/" + +# Protocol changers +#[url "https://github.com/"] +# insteadOf = ssh://github.com/ +# insteadOf = ssh://git@github.com/ +# insteadOf = git@github.com: + +#[url "ssh://git@github.com/"] +# insteadOf = https://github.com/ + +#[url "https://gitlab.com/"] +# insteadOf = ssh://gitlab.com/ +# insteadOf = ssh://git@gitlab.com/ +# insteadOf = git@gitlab.com: + +#[url "ssh://git@gitlab.com/"] +# insteadOf = https://gitlab.com/ diff --git a/.mailcap b/.mailcap index 2fac3c4..144dcfd 100644 --- a/.mailcap +++ b/.mailcap @@ -1,6 +1,5 @@ # MIME types -> viewers map, RFC 1524. -application/ogg; smplay %s; description="Ogg container files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" application/ogg; mplay %s; description="Ogg container files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" application/ogg; audtool --playlist-clear --playlist-addurl %s --playback-play; description="Ogg container files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 application/ogg; audacious %s; description="Ogg container files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" @@ -41,20 +40,16 @@ application/vnd.openxmlformats-officedocument.wordprocessingml.document; docx2tx audio/mpeg; audtool --playlist-clear --playlist-addurl %s --playback-play; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 audio/mpeg; audacious %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" audio/mpeg; foobar %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which foobar 2>/dev/null`" -audio/mpeg; smplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" audio/mpeg; mplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" audio/mpeg3; audtool --playlist-clear --playlist-addurl %s --playback-play; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 audio/mpeg3; audacious %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" audio/mpeg3; foobar %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which foobar 2>/dev/null`" -audio/mpeg3; smplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" audio/mpeg3; mplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" audio/mpegurl; audtool --playlist-clear --playlist-addurl %s --playback-play; description="MPEG URLs"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 -audio/mpegurl; smplay -playlist %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" audio/mpegurl; mplay -playlist %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" audio/ogg; audtool --playlist-clear --playlist-addurl %s --playback-play; description="Ogg Vorbis audio files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 audio/ogg; audacious %s; description="Ogg Vorbis audio files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" audio/ogg; foobar %s; description="Ogg Vorbis audio files"; test=test -n "$DISPLAY" -a -n "`which foobar 2>/dev/null`" -audio/ogg; smplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" audio/ogg; mplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" audio/x-mod; audtool --playlist-clear --playlist-addurl %s --playback-play; description="MOD audio files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 audio/x-mod; audacious %s; description="MOD audio files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" @@ -62,19 +57,16 @@ audio/x-mod; foobar %s; description="MOD audio files"; test=test -n "$DISPLAY" - audio/x-mpeg; audtool --playlist-clear --playlist-addurl %s --playback-play; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 audio/x-mpeg; audacious %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" audio/x-mpeg; foobar %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which foobar 2>/dev/null`" -audio/x-mpeg; smplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" audio/x-mpeg; mplay %s; description="MPEG audio files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" audio/x-pn-realaudio; realplay %s; description="RealAudio files"; test=test -n "$DISPLAY" -a -n "`which realplay 2>/dev/null`" audio/x-realaudio; realplay %s; description="RealAudio files"; test=test -n "$DISPLAY" -a -n "`which realplay 2>/dev/null`" audio/x-wav; audtool --playlist-clear --playlist-addurl %s --playback-play; description="WAV audio files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 audio/x-wav; audacious %s; description="WAV audio files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" audio/x-wav; foobar %s; description="WAV audio files"; test=test -n "$DISPLAY" -a -n "`which foobar 2>/dev/null`" -audio/x-wav; smplay %s; description="WAV audio files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" audio/x-wav; mplay %s; description="WAV audio files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" audio/*; audtool --playlist-clear --playlist-addurl %s --playback-play; description="Audio files"; test=test -n "$DISPLAY" -a -n "`which audtool 2>/dev/null`" && test "`audtool --get-volume`" -gt 0 audio/*; audacious %s; description="Audio files"; test=test -n "$DISPLAY" -a -n "`which audacious 2>/dev/null`" audio/*; foobar %s; description="Audio files"; test=test -n "$DISPLAY" -a -n "`which foobar 2>/dev/null`" -audio/*; smplay %s; description="Audio files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" audio/*; mplay %s; description="Audio files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" image/gif; xli %s; description="GIF image files"; test=test -n "$DISPLAY" -a -n "`which xli 2>/dev/null`" @@ -121,15 +113,10 @@ text/*; gview %s; edit=gvim -f %s; compose=gvim -f %s; description="Text"; test= text/*; less %s; edit=vim %s; needsterminal; description=Text; test=test -n "`which less 2>/dev/null`" text/*; more %s; edit=vi %s; needsterminal; description=Text; test=test -n "`which more 2>/dev/null`" -video/mpeg; smplay %s; description="MPEG video files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" video/mpeg; mplay %s; description="MPEG video files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" -video/ogg; smplay %s; description="Ogg Theora files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" video/ogg; mplay %s; description="Ogg Theora files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" -video/quicktime; smplay %s; description="QuickTime video files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" video/quicktime; mplay %s; description="QuickTime video files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" -video/x-msvideo; smplay %s; description="AVI video files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" video/x-msvideo; mplay %s; description="AVI video files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" -video/*; smplay %s; description="Video files"; test=test -n "$DISPLAY" -a -n "`which smplayer 2>/dev/null`" -a -n "`which smplay 2>/dev/null`" video/*; mplay %s; description="Video files"; test=test -n "$DISPLAY" -a -n "`which mplayer 2>/dev/null`" -a -n "`which mplay 2>/dev/null`" x-world/x-vrml; freewrl -url %s; test=test -n "$DISPLAY" -a -n "`which freewrl 2>/dev/null`"; description="VRML world"; nametemplate=%s.wrl diff --git a/.mc/ini b/.mc/ini index 0fc0804..3927168 100644 --- a/.mc/ini +++ b/.mc/ini @@ -16,12 +16,16 @@ confirm_view_dir=0 copymove_persistent_attr=1 double_click_speed=250 drop_menus=0 +editor_ask_filename_before_edit=false editor_backspace_through_tabs=0 editor_backup_extension=~ editor_check_new_line=0 +editor_cursor_after_inserted_block=false editor_cursor_beyond_eol=0 +editor_drop_selection_on_copy=true editor_edit_confirm_save=1 editor_fake_half_tabs=1 +editor_filesize_threshold=64M editor_fill_tabs_with_spaces=0 editor_group_undo=0 editor_key_emulation=0 @@ -35,6 +39,8 @@ editor_persistent_selections=1 editor_return_does_auto_indent=1 editor_show_right_margin=0 editor_simple_statusbar=0 +editor_state_full_filename=true +editor_stop_format_chars=-+*\\,.;:&> editor_syntax_highlighting=1 editor_tab_spacing=8 editor_visible_spaces=1 @@ -74,6 +80,7 @@ panel_scroll_pages=1 pause_after_run=2 preallocate_space=0 safe_delete=0 +safe_overwrite=false select_flags=6 shell_patterns=1 show_all_if_ambiguous=0 @@ -94,17 +101,18 @@ xtree_mode=0 [Layout] command_prompt=1 -equal_split=1 filetype_mode=1 free_space=1 horizontal_equal=1 horizontal_split=0 keybar_visible=1 +left_panel_size=0 menubar_visible=0 message_visible=0 output_lines=0 permission_mode=0 show_mini_info=1 +top_panel_size=1 vertical_equal=1 xterm_title=1 @@ -117,6 +125,7 @@ ftp_codepage=CP1251 ftp_proxy_host=gate ftpfs_password=anonymous@ source_codepage=Other_8_bit +spell_language=en timeformat_old=%b %e %Y timeformat_recent=%b %e %H:%M @@ -124,6 +133,7 @@ timeformat_recent=%b %e %H:%M base_color= color_terminals= rxvt= +screen.rxvt= [Panels] auto_save_setup_panels=false @@ -135,21 +145,29 @@ mark_moves_down=true mix_all_files=false mouse_move_pages=true navigate_with_arrows=false +panel_scroll_center=false panel_scroll_pages=true permission_mode=false quick_search_mode=2 reverse_files_only=true +select_flags=6 show_backups=true show_dot_files=true show_mini_info=true simple_swap=true torben_fj_mode=false -[terminal:rxvt] -backtab=\\e[Z -kpasterisk=\\eOj - [Panelize] Find *.orig after patching=find . -name \\*.orig -print Find SUID and SGID programs=find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print Find rejects after patching=find . -name \\*.rej -print + +[terminal:rxvt] +backtab=\\e[Z +kpasterisk=\\eOj + +[terminal:screen.rxvt] +backtab=\\e[Z +kpasterisk=\\eOj +kpminus=\\eOm +kpplus=\\eOk diff --git a/.mc/mc.ext b/.mc/mc.ext index b20df18..3284ff7 100644 --- a/.mc/mc.ext +++ b/.mc/mc.ext @@ -1,3 +1,131 @@ +### phd +# For MC version 3 + +Type/^Berkeley\ DB\ 1.85 +View=%view{ascii} db_dump185 -p %f + +# Compiled HTML +#Shell/.chm +#Open=fbreader %f & +# +## DejaVu +#Shell/.djvu +#Open=djview %f & +# +# EPUB +Shell/.epub +Open=fbreader %f & + +# FB2 +Shell/.fb2 +Open=fbreader %f & +View=%view{ascii} xsltproc /usr/local/src/distr/FictionBook/FB2_2_txt_ru.xsl %f + +#Type/^PostScript +#Open=libreoffice %f & +#View=%view{ascii} ps2ascii %f +# +# RTF +#Regex/i/\.rtf$ +#Open=fbreader %f & +#View=%view{ascii} catdoc %f +# +#Regex/i/\.(doc|wri)$ +#Include=msoffice-doc +# +Regex/i/\.docx$ +Edit=libreoffice %f & +Open=libreoffice %f & +View=%view{ascii} docx2txt %f - | iconv.py -f utf-8 + +Type/^Microsoft\ Word\ 2007+ +Include=msoffice-doc + +Type/^Microsoft\ Office\ Document +Include=msoffice-doc + +Regex/i/\.xlsx$ +Include=msoffice-xlsx + +Type/^Microsoft\ Excel\ 2007+ +Include=msoffice-xlsx + +#Type/^Composite\ Document\ File +#Include=msoffice-doc +# +# ftplist +Regex/\.ftplist$ +Open=%cd %p#ftplist + +# Play list +Regex/i/\.(m3u8?|pls)$ +Include=audio + +# Lossless audio +Regex/\.(cue|aac|ac3|ape|flac|wv|mka)$ +Include=audio + +## Object +#Shell/.o +#View=%view{ascii} nm %f +#Disassemble=%view{ascii} objdump -d -r %f +# +## Python +#Shell/.py +#Open=python %f +#View=%view{ascii} cat %f +#Compile=compyle %s +#Icon=snake.xpm + +# Conda/python packages +Regex/\.(conda|egg|whl)$ +Include=zip + +#Regex/i/\.tiff?$ +#Open=xview %f +# +Shell/.torrent +Open=%cd %p/torrent:// + +Regex/i/\.xml$ +Include=xml + +Type/^XML\ *(1\.0\ *)?document +Include=xml + +# LRE/Flibusta INPX +Regex/\.(inpx)$ +Include=zip + +Include/audio +#Open=[ "`audtool --get-volume`" -eq 0 ] && (cgmem_nice 200 audacious & sleep 3); audtool --playlist-clear; case %f in *.m3u8?) while read song; do audtool --playlist-addurl "$song"; done < %f ;; *) audtool --playlist-addurl %f ;; esac; audtool --playback-play +#Open=mplay %f & +Open=deadbeef %f & +View=%view{ascii} cat %f + +Include/msoffice-doc +Edit=libreoffice %f & +Open=libreoffice %f & +View=%view{ascii} catdoc %f + +Include/msoffice-xlsx +Edit=libreoffice %f & +Open=libreoffice %f & +View=%view{ascii} xlsx2csv %f | iconv.py -f utf-8 + +#Include/video +#Open=mplay %f & +#View=%view{ascii} cat %f +# +Include/xml +Open=%cd %p/xml:// + +Include/zip +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip + +### /phd + # Midnight Commander 3.0 extension file # Warning: Structure of this file has changed completely with version 3.0 # @@ -12,14 +140,23 @@ # i.e. matches all the files *desc . Example: .tar matches *.tar; # if it doesn't start with a dot, it matches only a file of that name) # +# shell/i (desc is, when starting with a dot, any extension (no wildcars), +# The same as shell but with case insensitive. +# # regex (desc is an extended regular expression) # Please note that we are using the GNU regex library and thus # \| matches the literal | and | has special meaning (or) and # () have special meaning and \( \) stand for literal ( ). # +# regex/i (desc is an extended regular expression) +# The same as regex but with case insensitive. +# # type (file matches this if `file %f` matches regular expression desc # (the filename: part from `file %f` is removed)) # +# type/i (file matches this if `file %f` matches regular expression desc) +# The same as type but with case insensitive. +# # directory (matches any directory matching regular expression desc) # # include (matches an include directive) @@ -40,7 +177,9 @@ # command is any one-line shell command, with the following substitutions: # # %% -> % character -# %p -> name of the current file (without path, but pwd is its path) +# %p -> name of the current file (without path, but pwd is its path). +# Also provided to external application as MC_EXT_BASENAME +# global variable # %f -> name of the current file. Unlike %p, if file is located on a # non-local virtual filesystem, i.e. either tarfs or ftpfs, # then the file will be temporarily copied into a local directory @@ -48,10 +187,18 @@ # If you don't want to get a local copy and want to get the # virtual fs path (like /#ftp:ftp.cvut.cz/pub/hungry/xword), then # use %d/%p instead of %f. +# Also provided to external application as MC_EXT_FILENAME +# global variable # %d -> name of the current directory (pwd, without trailing slash) +# Also provided to external application as MC_EXT_CURRENTDIR +# global variable # %s -> "selected files", i.e. space separated list of tagged files if any -# or name of the current file +# or name of the current file. +# Also provided to external application as MC_EXT_SELECTED +# global variable # %t -> list of tagged files +# Also provided to external application as MC_EXT_ONLYTAGGED +# global variable # %u -> list of tagged files (they'll be untaged after the command) # # (If these 6 letters are in uppercase, they refer to the other panel. @@ -87,215 +234,245 @@ ### Changes ### # -# Reorganization: 2000-05-01 Michal Svec - - -### TODO ### -# -# Postscript Open: ps2svga [gs -DEVICE=jpeg|zgv or something] -# Images asciiview -# -# All X Apps [Nothing/Warning] if no DISPLAY -# Not found [Default/Warning] -# Empty Output [Default/Warning] -# Edit: CopyOut+EDIT+CopyIn -# Security Check gzip/bzip EDIT (mktemp) -# -# Maybe: Open/XOpen/GOpen/KOpen/... for Console/X/GNOME/KDE/etc. +# Reorganization: 2012-03-07 Slava Zanko ### GIT Repo ### # gitfs changeset -regex/^\[git\] - Open=%cd %p/changesetfs:// - View=%cd %p/patchsetfs:// +Regex/^\[git\] +Open=%cd %p/changesetfs:// +View=%cd %p/patchsetfs:// ### Archives ### -# .tgz, .tpz, .tar.gz, .tar.z, .tar.Z, .ipk -regex/\.t([gp]?z|ar\.g?[zZ])$|\.ipk|\.gem$ - Open=%cd %p/utar:// - View=%view{ascii} gzip -dc %f 2>/dev/null | tar tvvf - +# .tgz, .tpz, .tar.gz, .tar.z, .tar.Z, .ipk, .gem +Regex/\.t([gp]?z|ar\.g?[zZ])$|\.ipk$|\.gem$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.gz -regex/\.tar\.bz$ - # Open=%cd %p/utar:// - View=%view{ascii} bzip -dc %f 2>/dev/null | tar tvvf - +Shell/.tar.bz +# Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.bzip -regex/\.t(ar\.bz2|bz2?|b2)$ - Open=%cd %p/utar:// - View=%view{ascii} bzip2 -dc %f 2>/dev/null | tar tvvf - +Regex/\.t(ar\.bz2|bz2?|b2)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.bzip2 # .tar.lzma, .tlz -regex/\.t(ar\.lzma|lz)$ - Open=%cd %p/utar:// - View=%view{ascii} lzma -dc %f 2>/dev/null | tar tvvf - +Regex/\.t(ar\.lzma|lz)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.lzma + +# .tar.lz +Shell/.tar.lz +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.lz + +# .tar.lz4, .tlz4 +Regex/\.t(ar\.lz4|lz4)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.lz4 # .tar.xz, .txz -regex/\.t(ar\.xz|xz)$ - Open=%cd %p/utar:// - View=%view{ascii} xz -dc %f 2>/dev/null | tar tvvf - +Regex/\.t(ar\.xz|xz)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.xz + +# .tar.zst, .tzst +Regex/\.t(ar\.zst|zst)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.zst # .tar.F - used in QNX -regex/\.tar\.F$ - # Open=%cd %p/utar:// - View=%view{ascii} freeze -dc %f 2>/dev/null | tar tvvf - +Shell/.tar.F +# Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.F # .qpr/.qpk - QNX Neutrino package installer files -regex/\.(qp[rk])$ - Open=%cd %p/utar:// - View=%view{ascii} gzip -dc %f 2>/dev/null | tar tvvf - +Regex/\.qp[rk]$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.qpr # tar -regex/\.(tar|TAR)$ - Open=%cd %p/utar:// - View=%view{ascii} tar tvvf - < %f +Shell/i/.tar +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar # lha -type/^LHa\ .*archive - Open=%cd %p/ulha:// - View=%view{ascii} lha l %f +Type/^LHa\ .*archive +Open=%cd %p/ulha:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lha # arj -regex/\.[aA]([rR][jJ]|[0-9][0-9])$ - Open=%cd %p/uarj:// - View=%view{ascii} unarj l %f +Regex/i/\.a(rj|[0-9][0-9])$ +Open=%cd %p/uarj:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view arj # cab -regex/\.([cC][aA][bB])$ - Open=%cd %p/ucab:// - View=%view{ascii} cabextract -l %f +Shell/i/.cab +Open=%cd %p/ucab:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cab # ha -regex/\.([Hh][Aa])$ - Open=%cd %p/uha:// - View=%view{ascii} ha lf %f +Shell/i/.ha +Open=%cd %p/uha:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view ha # rar -regex/\.[rR]([aA][rR]|[0-9][0-9])$ - Open=%cd %p/urar:// - View=%view{ascii} unrar v -c- %f +Regex/i/\.r(ar|[0-9][0-9])$ +Open=%cd %p/urar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view rar # ALZip -regex/\.(alz|ALZ)$ - Open=%cd %p/ualz:// - View=%view{ascii} unalz -l %f +Shell/i/.alz +Open=%cd %p/ualz:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view alz # cpio -shell/.cpio.Z - Open=%cd %p/ucpio:// - View=%view{ascii} gzip -dc %f | cpio -itv 2>/dev/null +Shell/.cpio.Z +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.z -shell/.cpio.xz - Open=%cd %p/ucpio:// - View=%view{ascii} xz -dc %f | cpio -itv 2>/dev/null +Shell/.cpio.lz +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.lz -shell/.cpio.gz - Open=%cd %p/ucpio:// - View=%view{ascii} gzip -dc %f | cpio -itv 2>/dev/null +Shell/.cpio.lz4 +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.lz4 -shell/.cpio - Open=%cd %p/ucpio:// - View=%view{ascii} cpio -itv < %f 2>/dev/null +Shell/.cpio.xz +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.xz -# ls-lR -regex/(^|\.)ls-?lR(\.gz|Z|bz2)$ - Open=%cd %p/lslR:// +Shell/.cpio.zst +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.zst + +Shell/.cpio.gz +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.gz + +Shell/i/.cpio +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio + +# initrd +Regex/^(initramfs.*\.img|initrd(-.+)?\.img(-.+)?)$ +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio + +# 7zip archives (they are not man pages) +Shell/i/.7z +Open=%cd %p/u7z:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view 7z # patch -regex/\.(diff|patch)(\.bz2)$ - Open=%cd %p/patchfs:// - View=%view{ascii} bzip2 -dc %f 2>/dev/null +Regex/\.(diff|patch)(\.bz2)$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view bz2 -regex/\.(diff|patch)(\.(gz|Z))$ - Open=%cd %p/patchfs:// - View=%view{ascii} gzip -dc %f 2>/dev/null +Regex/\.(diff|patch)(\.(gz|Z))$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view gz -regex/\.(diff|patch)$ - Open=%cd %p/patchfs:// - View=%view{ascii} /bin/cat %f 2>/dev/null +Regex/\.(diff|patch)(\.xz)$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view xz -# ar library -regex/\.s?a$ - Open=%cd %p/uar:// - #Open=%view{ascii} ar tv %f - View=%view{ascii} file %f && nm -C %f +Regex/\.(diff|patch)(\.zst)$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zst + +# ls-lR +Regex/(^|\.)ls-?lR(\.gz|Z|bz2)$ +Open=%cd %p/lslR:// # trpm -regex/\.trpm$ - Open=%cd %p/trpm:// - View=%view{ascii} rpm -qivl --scripts `basename %p .trpm` +Shell/.trpm +Open=%cd %p/trpm:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view trpm # RPM packages (SuSE uses *.spm for source packages) -regex/\.(src\.rpm|spm)$ - Open=%cd %p/rpm:// - View=%view{ascii} if rpm --nosignature --version >/dev/null 2>&1; then RPM="rpm --nosignature" ; else RPM="rpm" ; fi ; $RPM -qivlp --scripts %f +Regex/\.(src\.rpm|spm)$ +Open=%cd %p/rpm:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view src.rpm -regex/\.rpm$ - Open=%cd %p/rpm:// - View=%view{ascii} if rpm --nosignature --version >/dev/null 2>&1; then RPM="rpm --nosignature" ; else RPM="rpm" ; fi ; $RPM -qivlp --scripts %f +Shell/.rpm +Open=%cd %p/rpm:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view rpm # deb -regex/\.u?deb$ - Open=%cd %p/deb:// - View=%view{ascii} dpkg-deb -I %f && echo && dpkg-deb -c %f +Regex/\.u?deb$ +Open=%cd %p/deb:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view deb # dpkg -shell/.debd - Open=%cd %p/debd:// - View=%view{ascii} dpkg -s `echo %p | sed 's/\([0-9a-z.-]*\).*/\1/'` +Shell/.debd +Open=%cd %p/debd:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view debd + # apt -shell/.deba - Open=%cd %p/deba:// - View=%view{ascii} apt-cache show `echo %p | sed 's/\([0-9a-z.-]*\).*/\1/'` +Shell/.deba +Open=%cd %p/deba:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view deba # ISO9660 -regex/\.([iI][sS][oO](\.wv)?)$ - Open=%cd %p/iso9660:// - View=%view{ascii} isoinfo -l -i %f +Shell/i/.iso +Open=%cd %p/iso9660:// +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view iso9660 + + +Regex/\.(diff|patch)$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view cat + +# ar library +Regex/\.s?a$ +Open=%cd %p/uar:// +#Open=%view{ascii} ar tv %f +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view ar + +# gplib +Shell/i/.lib +Open=%cd %p/ulib:// +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view lib -# 7zip archives (they are not man pages) -regex/\.(7z|7Z)$ - Open=%cd %p/u7z:// - View=%view{ascii} 7za l %f 2>/dev/null # Mailboxes -type/^ASCII\ mail\ text - Open=%cd %p/mailfs:// +Type/^ASCII\ mail\ text +Open=%cd %p/mailfs:// ### Sources ### -# C -shell/.c - Include=editor - -# Fortran -shell/.f - Include=editor +# C/C++ +Regex/i/\.(c|cc|cpp)$ +Include=editor -# Header -regex/\.(h|hpp)$ - Include=editor +# C/C++ header +Regex/i/\.(h|hh|hpp)$ +Include=editor -# Asm -shell/.s - Include=editor +# Fortran +Shell/i/.f +Include=editor -# C++ -regex/\.(C|cc|cpp)$ - Include=editor +# Assembler +Regex/i/\.(s|asm)$ +Include=editor -include/editor - Open=%var{EDITOR:vi} %f +Include/editor +Open=%var{EDITOR:editor} %f # .so libraries -regex/\.(so|so\.[0-9\.]*)$ - View=%view{ascii} file %f && nm -C -D %f +Regex/\.(so|so\.[0-9\.]*)$ +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view so # Object -type/^ELF - #Open=%var{PAGER:more} %f - View=%view{ascii} file %f && nm -C %f +Type/^ELF +#Open=%var{PAGER:more} %f +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view elf ### Documentation ### @@ -303,502 +480,479 @@ type/^ELF #regex/\.(te?xi|texinfo)$ # GNU Info page -type/^Info\ text - Open=info -f %f +Type/^Info\ text +Open=/usr/lib/mc/ext.d/text.sh open info -shell/.info - Open=info -f %f +Shell/.info +Open=/usr/lib/mc/ext.d/text.sh open info # Exception: .3gp are video files not manual pages -regex/\.(3[gG][pP])$ - Include=video +Shell/i/.3gp +Include=video # Manual page -regex/(([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])|\.man)$ - Open=case %d/%f in */log/*|*/logs/*) cat %f ;; *) { zsoelim %f 2>/dev/null || cat %f; } | nroff -c -Tlatin1 -mandoc ;; esac | %var{PAGER:more} - View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) cat %f ;; *) { zsoelim %f 2>/dev/null || cat %f; } | nroff -c -Tlatin1 -mandoc ;; esac +Regex/(([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])|\.man)$ +Open=/usr/lib/mc/ext.d/text.sh open man %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man %var{PAGER:more} # Perl pod page -shell/.pod - Open=pod2man %f | nroff -c -Tlatin1 -mandoc | %var{PAGER:more} - View=%view{ascii,nroff} pod2man %f | nroff -c -Tlatin1 -mandoc +Shell/.pod +Open=/usr/lib/mc/ext.d/text.sh open pod %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view pod %var{PAGER:more} # Troff with me macros. # Exception - "read.me" is not a nroff file. -shell/read.me - Open= - View= +Shell/read.me +Open= +View= -shell/.me - Open=nroff -c -Tlatin1 -me %f | %var{PAGER:more} - View=%view{ascii,nroff} nroff -c -Tlatin1 -me %f +Shell/.me +Open=/usr/lib/mc/ext.d/text.sh open nroff.me %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view nroff.me %var{PAGER:more} # Troff with ms macros. -shell/.ms - Open=nroff -c -Tlatin1 -ms %f | %var{PAGER:more} - View=%view{ascii,nroff} nroff -c -Tlatin1 -ms %f +Shell/.ms +Open=/usr/lib/mc/ext.d/text.sh open nroff.ms %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view nroff.ms %var{PAGER:more} # Manual page - compressed -regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.g?[Zz]$ - Open=case %d/%f in */log/*|*/logs/*) gzip -dc %f ;; *) gzip -dc %f | nroff -c -Tlatin1 -mandoc ;; esac | %var{PAGER:more} - View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) gzip -dc %f ;; *) gzip -dc %f | nroff -c -Tlatin1 -mandoc ;; esac +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.g?[Zz]$ +Open=/usr/lib/mc/ext.d/text.sh open man.gz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.gz %var{PAGER:more} + +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.bz$ +Open=/usr/lib/mc/ext.d/text.sh open man.bz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.bz %var{PAGER:more} + +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.bz2$ +Open=/usr/lib/mc/ext.d/text.sh open man.bz2 %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.bz2 %var{PAGER:more} + +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lz$ +Open=/usr/lib/mc/ext.d/text.sh open man.lz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.lz %var{PAGER:more} -regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.bz$ - Open=case %d/%f in */log/*|*/logs/*) bzip -dc %f ;; *) bzip -dc %f | nroff -c -Tlatin1 -mandoc ;; esac | %var{PAGER:more} - View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) bzip -dc %f ;; *) bzip -dc %f | nroff -c -Tlatin1 -mandoc ;; esac +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lz4$ +Open=/usr/lib/mc/ext.d/text.sh open man.lz4 %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.lz4 %var{PAGER:more} -regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.bz2$ - Open=case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff -c -Tlatin1 -mandoc ;; esac | %var{PAGER:more} - View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff -c -Tlatin1 -mandoc ;; esac +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$ +Open=/usr/lib/mc/ext.d/text.sh open man.lzma %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.lzma %var{PAGER:more} -regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$ - Open=case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff -c -Tlatin1 -mandoc ;; esac | %var{PAGER:more} - View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff -c -Tlatin1 -mandoc ;; esac +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$ +Open=/usr/lib/mc/ext.d/text.sh open man.xz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.xz %var{PAGER:more} -regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$ - Open=case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff -c -Tlatin1 -mandoc ;; esac | %var{PAGER:more} - View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff -c -Tlatin1 -mandoc ;; esac +Regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.zst$ +Open=/usr/lib/mc/ext.d/text.sh open man.zst %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.zst %var{PAGER:more} # CHM -regex/\.(chm|CHM)$ - Open=which kchmviewer > /dev/null 2>&1 && (kchmviewer %f &) || (xchm %f &) +Shell/i/.chm +Open=/usr/lib/mc/ext.d/text.sh open chm ### Images ### -type/^GIF - Include=image +Type/^GIF +Include=image -type/^JPEG - View=%view{ascii} identify %f; test -x /usr/bin/exif && echo && exif %f 2>/dev/null - Include=image +Type/^JPEG +View=%view{ascii} /usr/lib/mc/ext.d/image.sh view jpeg +Include=image -type/^PC\ bitmap - Include=image +Type/^PC\ bitmap +Include=image -type/^PNG - Include=image +Type/^PNG +Include=image -type/^TIFF - Include=image +Type/^JNG +Include=image -type/^PBM - Include=image +Type/^MNG +Include=image -type/^PGM - Include=image +Type/^TIFF +Include=image -type/^PPM - Include=image +Type/^PBM +Include=image -type/^Netpbm - Include=image +Type/^PGM +Include=image -shell/.xcf - Open=(gimp %f &) +Type/^PPM +Include=image -shell/.xbm - Open=bitmap %f +Type/^Netpbm +Include=image -shell/.xpm - Include=image - View=sxpm %f +Shell/.xcf +Open=/usr/lib/mc/ext.d/image.sh open xcf -shell/.ico - Include=image +Shell/.xbm +Open=/usr/lib/mc/ext.d/image.sh open xbm -include/image - Open=(see %f &) - View=%view{ascii} identify %f - #View=%view{ascii} asciiview %f +Shell/.xpm +Include=image +View=/usr/lib/mc/ext.d/image.sh view xpm %f + +Shell/.ico +Include=image + +Shell/i/.svg +View=%view{ascii} /usr/lib/mc/ext.d/image.sh view svg +Open=/usr/lib/mc/ext.d/image.sh open svg + +Include/image +Open=/usr/lib/mc/ext.d/image.sh open ALL_FORMATS +View=%view{ascii} /usr/lib/mc/ext.d/image.sh view ALL_FORMATS ### Sound files ### -#regex/\.([wW][aA][vV]|[sS][nN][dD]|[vV][oO][cC]|[aA][uU]|[sS][mM][pP]|[aA][iI][fF][fF]|[sS][nN][dD])$ -# Open=if [ "$DISPLAY" = "" ]; then play %f; else (xmms %f >/dev/null 2>&1 &); fi -# -#regex/\.([mM][oO][dD]|[sS]3[mM]|[xX][mM]|[iI][tT]|[mM][tT][mM]|669|[sS][tT][mM]|[uU][lL][tT]|[fF][aA][rR])$ -# Open=mikmod %f -# #Open=tracker %f -# -#regex/\.([wW][aA][wW]22)$ -# Open=vplay -s 22 %f -# -#regex/\.([mM][pP]3)$ -# Open=if [ "$DISPLAY" = "" ]; then mpg123 %f; else (xmms %f >/dev/null 2>&1 &); fi -# View=%view{ascii} mpg123 -vtn1 %f 2>&1 | sed -n '/^Title/,/^Comment/p;/^MPEG/,/^Audio/p' -# -#regex/\.([oO][gG][gG|aA|vV|xX])$ -# Open=if [ "$DISPLAY" = "" ]; then ogg123 %f; else (xmms %f >/dev/null 2>&1 &); fi -# View=%view{ascii} ogginfo %s -# -#regex/\.([sS][pP][xX]|[fF][lL][aA][cC])$ -# Open=if [ "$DISPLAY" = "" ]; then play %f; else (xmms %f >/dev/null 2>&1 &); fi -# -#regex/\.([mM][iI][dD][iI]?|[rR][mM][iI][dD]?)$ -# Open=timidity %f -# -#regex/\.([wW][mM][aA])$ -# Open=mplayer -vo null %f -# View=%view{ascii} mplayer -quiet -slave -frames 0 -vo null -ao null -identify %f 2>/dev/null | tail +13 || file %f -# -# -#### Play lists ### -# -#regex/\.([mM]3[uU]|[pP][lL][sS])$ -# Open=if [ -z "$DISPLAY" ]; then mplayer -vo null -playlist %f; else (xmms -p %f >/dev/null 2>&1 &); fi +Regex/i/\.(wav|snd|voc|au|smp|aiff|snd|m4a|ape|aac|wv)$ +Open=/usr/lib/mc/ext.d/sound.sh open common + +Regex/i/\.(mod|s3m|xm|it|mtm|669|stm|ult|far)$ +Open=/usr/lib/mc/ext.d/sound.sh open mod + +Shell/i/.waw22 +Open=/usr/lib/mc/ext.d/sound.sh open wav22 + +Shell/i/.mp3 +Open=/usr/lib/mc/ext.d/sound.sh open mp3 +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view mp3 + +Regex/i/\.og[gax]$ +Open=/usr/lib/mc/ext.d/sound.sh open ogg +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view ogg + +Regex/i/\.(spx|flac)$ +Open=/usr/lib/mc/ext.d/sound.sh open common + +Regex/i/\.(midi?|rmid?)$ +Open=/usr/lib/mc/ext.d/sound.sh open midi + +Shell/i/.wma +Open=/usr/lib/mc/ext.d/sound.sh open wma +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view wma + + +### Play lists ### + +Regex/i/\.(m3u8?|pls)$ +Open=/usr/lib/mc/ext.d/sound.sh open playlist ### Video ### -regex/\.([aA][vV][iI])$ - Include=video +Shell/i/.avi +Include=video -regex/\.([aA][sS][fFxX])$ - Include=video +Regex/i/\.as[fx]$ +Include=video -regex/\.([dD][iI][vV][xX])$ - Include=video +Shell/i/.divx +Include=video -regex/\.([mM][kK][vV])$ - Include=video +Shell/i/.mkv +Include=video -regex/\.([mM][oO][vV]|[qQ][tT])$ - Include=video +Regex/i/\.(mov|qt)$ +Include=video -regex/\.([mM][pP]4|[mM]4[vV]|[mM][pP][eE]?[gG])$ - Include=video +Regex/i/\.(mp4|m4v|mpe?g)$ +Include=video # MPEG-2 TS container + H.264 codec -regex/\.([mM][tT][sS])$ - Include=video +Shell/i/.mts +Include=video + +Shell/i/.ts +Include=video -regex/\.([tT][sS])$ - Include=video +Shell/i/.vob +Include=video -regex/\.([vV][oO][bB])$ - Include=video +Shell/i/.wmv +Include=video -regex/\.([wW][mM][vV])$ - Include=video +Regex/i/\.fl[icv]$ +Include=video -regex/\.([fF][lL][iIcCvV])$ - Include=video +Shell/i/.ogv +Include=video -regex/\.([oO][gG][mM])$ - Include=video +Regex/i/\.ra?m$ +Open=/usr/lib/mc/ext.d/video.sh open ram -regex/\.([rR][aA]?[mM])$ - Open=(realplay %f >/dev/null 2>&1 &) +# WebM +Shell/i/.webm +Include=video -include/oldvideo - Open=(mplayer %f >/dev/null 2>&1 &) - #Open=(gtv %f >/dev/null 2>&1 &) - #Open=(xanim %f >/dev/null 2>&1 &) +Type/WebM +Include=video + +Include/video +Open=/usr/lib/mc/ext.d/video.sh open ALL_FORMATS +View=%view{ascii} /usr/lib/mc/ext.d/video.sh view ALL_FORMATS ### Documents ### # Postscript -type/^PostScript -# Open=(gv %f &) - View=%view{ascii} ps2ascii %f +Type/^PostScript +Open=/usr/lib/mc/ext.d/doc.sh open ps +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view ps # PDF -type/^PDF - Open=(see %f &) - #Open=(acroread %f &) - #Open=(ghostview %f &) - View=%view{ascii} pdftotext %f - - -# The following code very ugly and should not be taken as example. -# It should be cleaned up when the new format of mc.ext is developed. +Type/^PDF +Open=/usr/lib/mc/ext.d/doc.sh open pdf +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view pdf # html -regex/\.([hH][tT][mM][lL]?)$ - Open=(if test -n "" && test -n "$DISPLAY"; then ( file://%d/%p &) 1>&2; else links %f || lynx -force_html %f || ${PAGER:-more} %f; fi) 2>/dev/null - View=%view{ascii} links -dump %f 2>/dev/null || w3m -dump %f 2>/dev/null || lynx -dump -force_html %f +Regex/i/\.html?$ +Open=/usr/lib/mc/ext.d/web.sh open html +View=%view{ascii} /usr/lib/mc/ext.d/web.sh view html # StarOffice 5.2 -shell/.sdw - Open=(libreoffice %f &) +Shell/.sdw +Open=/usr/lib/mc/ext.d/doc.sh open ooffice # StarOffice 6 and OpenOffice.org formats -regex/\.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg)$ - Edit=(libreoffice %f &) - Open=(libreoffice %f &) - View=%view{ascii} odt2txt %f +Regex/i/\.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg)$ +Open=/usr/lib/mc/ext.d/doc.sh open ooffice +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view odt # AbiWord -shell/.abw - Open=(abiword %f &) +Shell/.abw +Open=/usr/lib/mc/ext.d/doc.sh open abw + +# Gnumeric +Shell/i/.gnumeric +Open=/usr/lib/mc/ext.d/doc.sh open gnumeric # Microsoft Word Document -#regex/\.([Dd][oO][cCtT]|[Ww][rR][iI])$ -# Open=(abiword %f >/dev/null 2>&1 &) -# View=%view{ascii} antiword -t %f || catdoc -w %f || word2x -f text %f - || strings %f -#type/^Microsoft\ Word -# Open=(abiword %f >/dev/null 2>&1 &) -# View=%view{ascii} antiword -t %f || catdoc -w %f || word2x -f text %f - || strings %f -# -## RTF document -#regex/\.([rR][tT][fF])$ -# Open=(abiword %f >/dev/null 2>&1 &) +Regex/i/\.(do[ct]|wri|docx)$ +Open=/usr/lib/mc/ext.d/doc.sh open msdoc +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msdoc +Type/^Microsoft\ Word +Open=/usr/lib/mc/ext.d/doc.sh open msdoc +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msdoc -# Microsoft Excel Worksheet -regex/\.([xX][lL][sSwW])$ - Open=(gnumeric %f >/dev/null 2>&1 &) - View=%view{ascii} xls2csv %f || strings %f -type/^Microsoft\ Excel - Open=(gnumeric %f >/dev/null 2>&1 &) - View=%view{ascii} xls2csv %f || strings %f +# RTF document +Shell/i/.rtf +Open=/usr/lib/mc/ext.d/doc.sh open msdoc -# Use OpenOffice.org to open any MS Office documents -#type/^Microsoft\ Office\ Document -# Open=(libreoffice %f &) +# Microsoft Excel Worksheet +Regex/i/\.(xl[sw]|xlsx)$ +Open=/usr/lib/mc/ext.d/doc.sh open msxls +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msxls +Type/^Microsoft\ Excel +Open=/usr/lib/mc/ext.d/doc.sh open msxls +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msxls + +# Microsoft PowerPoint Presentation +Regex/i/\.(pp[ts]|pptx)$ +Open=/usr/lib/mc/ext.d/doc.sh open msppt +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msppt + +# Use OpenOffice.org/LibreOffice to open any MS Office documents +Type/^Microsoft\ Office\ Document +Open=/usr/lib/mc/ext.d/doc.sh open ooffice +Type/^Microsoft\ OOXML +Open=/usr/lib/mc/ext.d/doc.sh open ooffice # Framemaker -type/^FrameMaker - Open=fmclient -f %f +Type/^FrameMaker +Open=/usr/lib/mc/ext.d/doc.sh open framemaker # DVI -regex/\.([dD][vV][iI])$ - Open=run-mailcap %f 2>&1 & - View=%view{ascii} catdvi %f +Shell/i/.dvi +Open=/usr/lib/mc/ext.d/doc.sh open dvi +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view dvi # TeX -regex/\.([Tt][Ee][Xx])$ - Include=editor +Shell/i/.tex +Include=editor # DjVu -regex/\.(djvu?|DJVU?)$ - Open=djview %f & - View=%view{ascii} djvused -e print-pure-txt %f +Regex/i/\.djvu?$ +Open=/usr/lib/mc/ext.d/doc.sh open djvu +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view djvu + +# Comic Books +Regex/i/\.cb[zr]$ +Open=/usr/lib/mc/ext.d/doc.sh open comic + +# Epub & mobi +Regex/i/\.(epub|mobi)$ +Open=/usr/lib/mc/ext.d/doc.sh open epub +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view epub + ### Miscellaneous ### +# Compiled Java classes +Shell/.class +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view javaclass + # Makefile -regex/[Mm]akefile$ - Open=make -f %f %{Enter parameters} +Regex/^[Mm]akefile$ +Open=make -f %f %{Enter parameters} # Imakefile -shell/Imakefile - Open=xmkmf -a +Shell/Imakefile +Open=xmkmf -a # Makefile.PL (MakeMaker) -regex/^Makefile.(PL|pl)$ - Open=%var{PERL:perl} %f +Regex/^Makefile\.(PL|pl)$ +Open=%var{PERL:perl} %f + +# sqlite3.db +Type/^SQLite\ 3.x\ database +Open=/usr/lib/mc/ext.d/misc.sh open sqlite +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view sqlite # dbf -regex/\.([dD][bB][fF])$ - Open=%view{ascii} dbview %f - View=%view{ascii} dbview -b %f +Shell/i/.dbf +Open=/usr/lib/mc/ext.d/misc.sh open dbf +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view dbf # REXX script -regex/\.(rexx?|cmd)$ - Open=rexx %f %{Enter parameters};echo "Press ENTER";read y +Regex/\.(rexx?|cmd)$ +Open=rexx %f %{Enter parameters};echo "Press ENTER";read y # Disk images for Commodore computers (VIC20, C64, C128) -regex/\.(d64|D64)$ - Open=%cd %p/uc1541:// - View=%view{ascii} c1541 %f -list - Extract=c1541 %f -extract +Shell/i/.d64 +Open=%cd %p/uc1541:// +View=%view{ascii} c1541 %f -list +Extract=c1541 %f -extract # Glade, a user interface designer for GTK+ and GNOME -regex/\.([Gg][Ll][Aa][Dd][Ee])$ - Open=if glade-3 --version >/dev/null 2>&1; then (glade-3 %f >/dev/null 2>&1 &); else (glade-2 %f >/dev/null 2>&1 &); fi +Shell/i/.glade +Open=/usr/lib/mc/ext.d/misc.sh open glade # Gettext Catalogs -shell/.mo - View=%view{ascii} msgunfmt %f || cat %f +Regex/\.g?mo$ +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view mo + +# po +Shell/.po +Open=/usr/lib/mc/ext.d/misc.sh open po # lyx -regex/\.(lyx|LYX)$ - Open=lyx %f - View=%view{ascii} lyxcat %f +Shell/i/.lyx +Open=/usr/lib/mc/ext.d/misc.sh open lyx +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view lyx # torrent -#regex/\.([tT][oO][rR][rR][eE][nN][tT])$ -# View=%view{ascii} ctorrent -x %f 2>/dev/null +Shell/i/.torrent +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view torrent ### Plain compressed files ### # ace -regex/\.(ace|ACE)$ - Open=%cd %p/uace:// - View=%view{ascii} unace l %f - Extract=unace x %f +Shell/i/.ace +Open=%cd %p/uace:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view ace +Extract=unace x %f # arc -regex/\.(arc|ARC)$ - Open=%cd %p/uarc:// - View=%view{ascii} arc l %f - Extract=arc x %f '*' - Extract (with flags)=I=%{Enter any Arc flags:}; if test -n "$I"; then arc x $I %f; fi +Shell/i/.arc +Open=%cd %p/uarc:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view arc +Extract=arc x %f '*' +Extract (with flags)=I=%{Enter any Arc flags:}; if test -n "$I"; then arc x $I %f; fi + +# zip +Shell/i/.zip +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip # zip -type/^([Zz][Ii][Pp])\ archive - Open=%cd %p/uzip:// - View=%view{ascii} unzip -v %f +Type/i/^zip\ archive +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip + +# jar(zip) +Type/i/^Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\) +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip # zoo -regex/\.([Zz][Oo][Oo])$ - Open=%cd %p/uzoo:// - View=%view{ascii} zoo l %f +Shell/i/.zoo +Open=%cd %p/uzoo:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zoo # gzip -type/^gzip - Open=gzip -dc %f | %var{PAGER:more} - View=%view{ascii} gzip -dc %f 2>/dev/null +Type/^gzip +Open=/usr/lib/mc/ext.d/archive.sh view gz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view gz -regex/\.(gz|Z)$ - View=%view{ascii} gzip -dc %f 2>/dev/null +Regex/\.(gz|Z)$ +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view gz # bzip2 -type/^bzip2 - Open=bzip2 -dc %f | %var{PAGER:more} - View=%view{ascii} bzip2 -dc %f 2>/dev/null +Type/^bzip2 +Open=/usr/lib/mc/ext.d/archive.sh view bzip2 %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view bz2 -regex/\.bz2?$ - View=%view{ascii} bzip2 -dc %f 2>/dev/null +Regex/\.bz2?$ +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view bz2 # bzip -type/^bzip - Open=bzip -dc %f | %var{PAGER:more} - View=%view{ascii} bzip -dc %f 2>/dev/null +Type/^bzip +Open=/usr/lib/mc/ext.d/archive.sh view bzip %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view bzip # compress -type/^compress - Open=gzip -dc %f | %var{PAGER:more} - View=%view{ascii} gzip -dc %f 2>/dev/null - -# lzma -regex/\.lzma$ - Open=lzma -dc %f | %var{PAGER:more} - View=%view{ascii} lzma -dc %f 2>/dev/null - -# xz -regex/\.xz$ - Open=xz -dc %f | %var{PAGER:more} - View=%view{ascii} xz -dc %f 2>/dev/null - -### phd - -type/^Berkeley\ DB\ 1.85 - View=%view{ascii} db_dump185 -p %f - -# Compiled HTML -shell/.chm - Open=fbreader %f & - -# DejaVu -shell/.djvu - Open=djview %f & - #Open=evince %f & - #Open=qpdfview %f & - -# EPUB -shell/.epub - Open=fbreader %f & - -# FB2 -shell/.fb2 - Open=fbreader %f & - View=%view{ascii} xsltproc /usr/local/src/FictionBook/FB2_2_txt_ru.xsl %f - -type/^PostScript - #Open=evince %f & - Open=qpdfview %f & - View=%view{ascii} ps2ascii %f - -# RTF -regex/\.([rR][tT][fF])$ - Open=fbreader %f & - View=%view{ascii} catdoc %f +Type/^compress +Open=/usr/lib/mc/ext.d/archive.sh view gz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view gz -regex/\.([Dd][oO][cCtT]|[Ww][rR][iI])$ - Include=msoffice +# lz +Regex/\.lz$ +Open=/usr/lib/mc/ext.d/archive.sh view lz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lz -regex/\.([Dd][oO][cC][Xx])$ - Edit=libreoffice %f & - Open=libreoffice %f & - View=%view{ascii} docx2txt %f - | iconv.py -f utf-8 +# lz +Type/^LZIP +Open=/usr/lib/mc/ext.d/archive.sh view lz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lz -type/^Microsoft\ Word - Include=msoffice +# lz4 +Regex/\.lz4$ +Open=/usr/lib/mc/ext.d/archive.sh view lz4 %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lz4 -type/^Microsoft\ Office\ Document - Include=msoffice - -type/^Composite\ Document\ File - Include=msoffice - -# ftplist -regex/\.ftplist$ - Open=%cd %p#ftplist - -# Play list -regex/\.([mM]3[uU]|[pP][lL][sS])$ - Include=audio - -# Lossless audio -regex/\.(cue|aac|ac3|ape|flac|wv|mka)$ - Include=audio - -# Object -shell/.o - View=%view{ascii} nm %f - Disassemble=%view{ascii} objdump -d -r %f - -# Python -shell/.py - Open=python %f - View=%view{ascii} - Compile=compyle %s - Icon=snake.xpm - -regex/\.(tif|TIF|tiff|TIFF)$ - Open=xview %f - -shell/.torrent - Open=%cd %p/torrent:// - -regex/\.([xX][mM][lL])$ - Include=xml - -type/^XML *(1\.0 *)?document - Include=xml - -regex/\.([Zz][Ii][Pp])$ - Open=%cd %p/uzip:// - View=%view{ascii} unzip -v %f - -include/audio - #Open=[ "`audtool --get-volume`" -eq 0 ] && (audacious & sleep 3); audtool --playlist-clear --playlist-addurl %f --playback-play - #Open=mplayer %f & - Open=deadbeef %f & - #Open=mediaplayer_open %f - View=%view{ascii} %f +# lzma +Regex/\.lzma$ +Open=/usr/lib/mc/ext.d/archive.sh view lzma %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lzma -include/msoffice - Edit=libreoffice %f & - Open=libreoffice %f & - View=%view{ascii} catdoc %f +# xz +Regex/\.xz$ +Open=/usr/lib/mc/ext.d/archive.sh view xz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view xz -include/video - Open=mplayer %f & - #Open=mediaplayer_open %f - View=%view{ascii} %f +# zstd +Regex/\.zst$ +Open=/usr/lib/mc/ext.d/archive.sh view zst %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zst -include/xml - Open=%cd %p/xml:// +# Parity Archive +Type/^Parity\ Archive\ Volume\ Set +Open=/usr/lib/mc/ext.d/archive.sh open par2 ### Default ### # Default target for anything not described above -default/* - Open= - View= +Default/* +Open= +View= ### EOF ### diff --git a/.mc/mc.ext.ini b/.mc/mc.ext.ini new file mode 100644 index 0000000..51475db --- /dev/null +++ b/.mc/mc.ext.ini @@ -0,0 +1,1266 @@ +# Midnight Commander 4.0 extension file +# +# Warning: The structure of this file has been completely changed with the version 4.0! +# +# All lines starting with # or empty lines are ignoted. +# +# IMPORTANT: mc scans this file only upon first use or after editing it using the +# mc "Edit extension file" command (F9-c-e). If you edit this file in any other way +# while mc is running, you will need to press F9-c-e and exit the editor for your +# changes to take effect, or exit mc and start it again. +# +# Section name can be anything with following exceptions: +# there are two reserved section names: +# mc.ext.ini +# Default +# special name pattern: +# Include/xxxxx +# See below for more details. +# +# Section [mc.ext.ini] is mandatory. It contains file metadata. +# "Version" parameter is mandatory. It contains the file format version. +# +# Section [Default] is optional. It is applied only if no other match was found. +# +# Sections like [Include/xxxx] can be referenced as "Include=xxxx" from other sections. +# Section [Include/xxxx] can be located as before as after sections that point to it. +# +# Sections are processed from top to bottom, thus the order is important. +# If there are more than one sections with the same name in this file, the first +# section will be used. +# +# [Default] should be a catch-all action and come last. +# +# A section describing a file can contain following keys: +# +# File descriptions: +# +# Directory +# Matches any directory matching regular expression. +# Always case sensitive. +# This key has the highest priority over other keys. If this key is in a section, +# other keys are ignored. +# +# Type +# Matches files if `file %f` matches regular expression +# (the "filename:" part is removed from `file %f` output). +# Ignored if the "file" utility isn't used (not found during the configure step +# or disabled in the ini-file). +# +# TypeIgnoreCase [true|false] +# Defines whether the Type value is case sensitive or not. +# If absent, Type is case sensitive. +# +# Regex +# An extended regular expression +# Please note that we are using the PCRE library and thus \| matches +# the literal | and | has a special meaning (or), and () have a special meaning +# and \( \) stand for literal ( ). +# +# Example: +# Regex=\.t(ar\.lzma|lz)$ +# matches *.tar.lzma or *.tlz. +# +# RegexIgnoreCase [true|false] +# Defines whether the Regex value is case sensitive or not. +# If absent, Regex is case sensitive. +# +# Shell +# Describes an extension when starting with a dot (no wildcards). +# +# Example: +# Shell=.tar +# matches *.tar. +# +# If it doesn't start with a dot, it matches only a file of that name. +# +# If both keys Regex and Shell are in the same section, Regex is used +# and Shell is ignored. +# +# ShellIgnoreCase [true|false] +# Defines whether the Shell value is case sensitive or not. +# If absent, Shell is case sensitive. +# +# Include +# Reference to another section. +# +# Example: +# Include=video +# points to the [Include/video] section. +# +# Commands: +# +# Open +# Execute the command if the user presses Enter or doubleclicks it. +# +# View +# Execute the command if the user presses F3. +# +# Edit +# Execute the command if the user presses F4. +# +# All commands are ignored if the section contains the Include key. +# +# Command is any one-line shell command, with the following substitutions: +# +# %% +# The % character +# +# %p +# Name of the current file without the path. +# Also provided to the external application as MC_EXT_BASENAME environment variable. +# +# %f +# Name of the current file. Unlike %p, if the file is located on a non-local +# virtual filesystem, that is either tarfs or ftpfs, then the file will be +# temporarily copied into a local directory and %f will be the full path +# to this local temporary file. +# If you don't want to get a local copy and want to get the virtual fs path +# (like /ftp://ftp.cvut.cz/pub/hungry/xword), then use %d/%p instead of %f. +# Also provided to the external application as MC_EXT_FILENAME environment variable. +# +# %d +# Name of the current directory without the trailing slash (`pwd`). +# Also provided to the external application as MC_EXT_CURRENTDIR environment variable. +# +# %s +# "Selected files", that is space separated list of tagged files if any or the name +# of the current file. +# Also provided to the external application as MC_EXT_SELECTED environment variable. +# +# %t +# List of the tagged files. +# Also provided to the external application as MC_EXT_ONLYTAGGED environment variable. +# +# %u +# List of the tagged files (they will be untaged after the command is executed). +# +# (If the letter following the % is uppercase, then it refers to the opposite panel. +# But you shouldn't have to use it in this file.) +# +# %cd +# The rest is a path mc should change into (cd won't work, since it's a child process). +# %cd handles even vfs names. +# +# %view +# The command output will be piped into mc's internal file viewer. If you use +# only %view and no command, the viewer will load %f file instead (that is no piping, +# which is the difference to %view cat %f). +# +# %view may be directly followed by {} with one or more of the following +# separated by commas: +# ascii (ascii mode) +# hex (hex mode), +# nroff (color highlighting for text using escape sequences), +# unform (no highlighting for nroff sequences) +# +# %var{VAR:default} +# This macro will expand to the value of the VAR variable in the environment if it's +# set, otherwise the default value will be used. This is similar to the Bourne shell +# ${VAR-default} construct. +# +# Section can contain both Type and Regex or Type and Shell keys. In this case +# they are handled as an AND condition. +# +# Example: +# Shell=.3gp +# Type=^ISO Media.*3GPP +# +# matches *.3gp files for which `file` output is a line starting with "ISO Media" +# and containing "3GPP". +# +# If there are more than one keys with the same name in a section, the last key will be used. +# +# +# Any new entries you want to add are always welcome if they are useful on more than one +# system. You can post your modifications as tickets at www.midnight-commander.org. + + +### Changes ### +# +# Reorganization: 2012-03-07 Slava Zanko +# 2021-03-28 Andrew Borodin +# 2021-08-24 Tomas Szepe +# 2022-09-11 Andrew Borodin : port to INI format. + +[mc.ext.ini] +Version=4.0 + +### phd +# For MC version 4 + +[Berkeley DB 1.85] +Type=^Berkeley\ DB\ 1.85 +View=%view{ascii} db_dump185 -p %f + +# [Compiled HTML] +#Shell=.chm +#Open=fbreader %f & +# +## [DejaVu] +#Shell=.djvu +#Open=djview %f & +# +[EPUB] +Shell=.epub +Open=fbreader %f & + +[FB2] +Shell=.fb2 +Open=fbreader %f & +View=%view{ascii} xsltproc /usr/local/src/distr/FictionBook/FB2_2_txt_ru.xsl %f + +#[PostScript] +#Type=^PostScript +#Open=libreoffice %f & +#View=%view{ascii} ps2ascii %f + +#[RTF] +#Regex=\.rtf$ +#Open=fbreader %f & +#View=%view{ascii} catdoc %f + +#[doc-wri] +#Regex=\.(doc|wri)$ +#Include=msoffice-doc + +[docs] +Regex=\.docx$ +Edit=libreoffice %f & +Open=libreoffice %f & +View=%view{ascii} docx2txt %f - | iconv.py -f utf-8 + +#[Composite Document File] +#Type=^Composite\ Document\ File +#Include=msoffice-doc + +[Microsoft Word 2007] +Type=^Microsoft\ Word\ 2007+ +Include=msoffice-doc + +[Microsoft Office Document] +Type=^Microsoft\ Office\ Document +Include=msoffice-doc + +[xlsx] +Regex=\.xlsx$ +Include=msoffice-xlsx + +[/^Microsoft Excel 2007+] +Include=msoffice-xlsx + +[ftplist] +Regex=\.ftplist$ +Open=%cd %p#ftplist + +[Play list] +Regex=\.(m3u8?|pls)$ +Include=audio + +[Lossless audio] +Regex=\.(cue|aac|ac3|ape|flac|wv|mka)$ +Include=audio + +## Object +#Shell=.o +#View=%view{ascii} nm %f +#Disassemble=%view{ascii} objdump -d -r %f +# +## Python +#Shell=.py +#Open=python %f +#View=%view{ascii} cat %f +#Compile=compyle %s +#Icon=snake.xpm + +[Conda/python packages] +Regex=\.(conda|egg|whl)$ +Include=zip + +# TIFF +#Regex=\.tiff?$ +#Open=xview %f + +[torrent] +Shell=.torrent +Open=%cd %p/torrent:// + +[xml-ext] +Regex=\.xml$ +Include=xml + +[xml-type] +Type=^XML\ *(1\.0\ *)?document +Include=xml + +[LRE/Flibusta INPX] +Regex=\.(inpx)$ +Include=zip + +[Include/audio] +#Open=[ "`audtool --get-volume`" -eq 0 ] && (cgmem_nice 200 audacious & sleep 3); audtool --playlist-clear; case %f in *.m3u8?) while read song; do audtool --playlist-addurl "$song"; done < %f ;; *) audtool --playlist-addurl %f ;; esac; audtool --playback-play +#Open=mplay %f & +Open=deadbeef %f & +View=%view{ascii} cat %f + +[Include/msoffice-doc] +Edit=libreoffice %f & +Open=libreoffice %f & +View=%view{ascii} catdoc %f + +[Include/msoffice-xlsx] +Edit=libreoffice %f & +Open=libreoffice %f & +View=%view{ascii} xlsx2csv %f | iconv.py -f utf-8 + +#[Include/video] +#Open=mplay %f & +#View=%view{ascii} cat %f + +[Include/xml] +Open=%cd %p/xml:// + +[Include/zip] +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip + +### /phd + +### GIT Repo ### +[gitfs changeset] +Regex=^\[git\] +Open=%cd %p/changesetfs:// +View=%cd %p/patchsetfs:// + +### Archives ### +# Since we use "file -z", we should use Regex and Shell first, then Type. + + +######### Files by name (Regex and Shell) ######### + +# .tgz, .tpz, .tar.gz, .tar.z, .tar.Z +[tar.gzip] +Regex=\.t([gp]?z|ar\.g?[zZ])$ +Include=tar.gz + +[ipk] +Shell=.ipk +Include=tar.gz + +[gem] +Shell=.gem +Include=tar.gz + +[tar.bzip] +Shell=.tar.bz +# Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.bzip + +[tar.bzip2] +Regex=\.t(ar\.bz2|bz2?|b2)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.bzip2 + +# .tar.lzma, .tlz +[tar.lzma] +Regex=\.t(ar\.lzma|lz)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.lzma + +[tar.lz] +Shell=.tar.lz +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.lz + +# .tar.lz4, .tlz4 +[tar.lz4] +Regex=\.t(ar\.lz4|lz4)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.lz4 + +# .tar.xz, .txz +[tar.xz] +Regex=\.t(ar\.xz|xz)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.xz + +# .tar.zst, .tzst +[tar.zst] +Regex=\.t(ar\.zst|zst)$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.zst + +# .tar.F - used on QNX +[tar.F] +Shell=.tar.F +# Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.F + +# .qpr/.qpk - QNX Neutrino package installer files +[tar.qpr] +Regex=\.qp[rk]$ +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.qpr + +[tar] +Shell=.tar +ShellIgnoreCase=true +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar + +[arj] +Regex=\.a(rj|[0-9][0-9])$ +RegexIgnoreCase=true +Open=%cd %p/uarj:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view arj + +[cab] +Shell=.cab +ShellIgnoreCase=true +Open=%cd %p/ucab:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cab + +[ha] +Shell=.ha +ShellIgnoreCase=true +Open=%cd %p/uha:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view ha + +[rar] +Regex=\.r(ar|[0-9][0-9])$ +RegexIgnoreCase=true +Open=%cd %p/urar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view rar + +# ALZip +[alz] +Shell=.alz +ShellIgnoreCase=true +Open=%cd %p/ualz:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view alz + +[cpio.Z] +Shell=.cpio.Z +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.z + +[cpio.lz] +Shell=.cpio.lz +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.lz + +[cpio.lz4] +Shell=.cpio.lz4 +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.lz4 + +[cpio.xz] +Shell=.cpio.xz +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.xz + +[cpio.zst] +Shell=.cpio.zst +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.zst + +[cpio.gz] +Shell=.cpio.gz +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio.gz + +[cpio] +Shell=.cpio +ShellIgnoreCase=true +Include=cpio + +[initrd] +Regex=^(initramfs.*\.img|initrd(-.+)?\.img(-.+)?)$ +Include=cpio + +[7zip] +Shell=.7z +ShellIgnoreCase=true +Open=%cd %p/u7z:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view 7z + +[patch] +Regex=\.(diff|patch)$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view cat + +[patch.gz] +Regex=\.(diff|patch)\.(gz|Z)$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view gz + +[patch.bz2] +Regex=\.(diff|patch)\.bz2$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view bz2 + +[patch.xz] +Regex=\.(diff|patch)\.xz$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view xz + +[patch.zst] +Regex=\.(diff|patch)\.zst$ +Open=%cd %p/patchfs:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zst + +[ls-lR] +Regex=(^|\.)ls-?lR(\.gz|Z|bz2)$ +Open=%cd %p/lslR:// + +[trpm] +Shell=.trpm +Open=%cd %p/trpm:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view trpm + +# RPM packages (SuSE uses *.spm for source packages) +[src.rpm] +Regex=\.(src\.rpm|spm)$ +Open=%cd %p/rpm:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view src.rpm + +[rpm] +Shell=.rpm +Open=%cd %p/rpm:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view rpm + +[deb] +Regex=\.u?deb$ +Open=%cd %p/deb:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view deb + +[dpkg] +Shell=.debd +Open=%cd %p/debd:// +View=%view{ascii} /usr/lib/mc/ext.d/package.sh view debd + +[apt] +Shell=.deba +Open=%cd %p/deba:// +Ciew=%view{ascii} /usr/lib/mc/ext.d/package.sh view deba + +[ISO9660] +Shell=.iso +ShellIgnoreCase=true +Open=%cd %p/iso9660:// +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view iso9660 + +[ar] +Regex=\.s?a$ +Open=%cd %p/uar:// +#Open=%view{ascii} ar tv %f +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view ar + +[gplib] +Shell=.lib +ShellIgnoreCase=true +Open=%cd %p/ulib:// +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view lib + +### Sources ### + +[C/C++] +Regex=\.(c|cc|cpp|cxx|c\+\+)$ +RegexIgnoreCase=true +Include=editor + +[C/C++ header] +Regex=\.(h|hh|hpp|hxx|h\+\+)$ +RegexIgnoreCase=true +Include=editor + +[Fortran] +Shell=.f +ShellIgnoreCase=true +Include=editor + +[Assembler] +Regex=\.(s|asm)$ +RegexIgnoreCase=true +Include=editor + +[Typescript] +Shell=.ts +ShellIgnoreCase=true +Type=^Java source +Include=editor + +# .so libraries +[so] +Regex=\.(so|so\.[0-9\.]*)$ +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view so + + +### Documentation ### + +#[Texinfo] +#Regex=\.(te?xi|texinfo)$ + +[info-by-shell] +Shell=.info +Open=/usr/lib/mc/ext.d/text.sh open info + +# Exception: .3gp are video files, not manual pages +[3gp] +Shell=.3gp +ShellIgnoreCase=true +Type=^ISO Media.*3GPP +Include=video + +# Troff with me macros. +# Exception - "read.me" is not a nroff file. +[read.me] +Shell=read.me +Open= +View= + +[troff] +Shell=.me +Open=/usr/lib/mc/ext.d/text.sh open nroff.me %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view nroff.me %var{PAGER:more} + +[roff with ms macros] +Shell=.ms +Open=/usr/lib/mc/ext.d/text.sh open nroff.ms %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view nroff.ms %var{PAGER:more} + +# Manual page + +[man.lz] +Regex=([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lz$ +Open=/usr/lib/mc/ext.d/text.sh open man.lz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.lz %var{PAGER:more} + +[man.lz4] +Regex=([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lz4$ +Open=/usr/lib/mc/ext.d/text.sh open man.lz4 %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.lz4 %var{PAGER:more} + +[man.lzma] +Regex=([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$ +Open=/usr/lib/mc/ext.d/text.sh open man.lzma %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.lzma %var{PAGER:more} + +[man.xz] +Regex=([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$ +Open=/usr/lib/mc/ext.d/text.sh open man.xz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.xz %var{PAGER:more} + +[man.zst] +Regex=([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.zst$ +Open=/usr/lib/mc/ext.d/text.sh open man.zst %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.zst %var{PAGER:more} + +# Perl pod page +[pod] +Shell=.pod +Open=/usr/lib/mc/ext.d/text.sh open pod %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view pod %var{PAGER:more} + +[chm] +Shell=.chm +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/text.sh open chm + +### Images ### + +[xcf] +Shell=.xcf +Open=/usr/lib/mc/ext.d/image.sh open xcf + +[xbm] +Shell=.xbm +Open=/usr/lib/mc/ext.d/image.sh open xbm + +[xpm] +Shell=.xpm +Include=image + +[ico] +Shell=.ico +Include=image + +[svg] +Shell=.svg +ShellIgnoreCase=true +View=%view{ascii} /usr/lib/mc/ext.d/image.sh view svg +Open=/usr/lib/mc/ext.d/image.sh open svg + + +### Sound files ### + +[sound] +Regex=\.(wav|snd|voc|au|smp|aiff|snd|m4a|ape|aac|wv|spx|flac)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open common +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view common + +[mod] +Regex=\.(mod|s3m|xm|it|mtm|669|stm|ult|far)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open mod + +[wav22] +Shell=.waw22 +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open wav22 + +[mp3] +Shell=.mp3 +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open mp3 +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view mp3 + +[ogg] +Regex=\.og[gax]$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open ogg +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view ogg + +[opus] +Shell=.opus +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open opus +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view opus + +[midi] +Regex=\.(midi?|rmid?)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open midi + +[wma] +Shell=.wma +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open wma +View=%view{ascii} /usr/lib/mc/ext.d/sound.sh view wma + +# Play list +[playlist] +Regex=\.(m3u|pls)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/sound.sh open playlist + + +### Video ### + +[avi] +Shell=.avi +ShellIgnoreCase=true +Include=video + +[asf] +Regex=\.as[fx]$ +RegexIgnoreCase=true +Include=video + +[divx] +Shell=.divx +ShellIgnoreCase=true +Include=video + +[mkv] +Shell=.mkv +ShellIgnoreCase=true +Include=video + +[mov] +Regex=\.(mov|qt)$ +RegexIgnoreCase=true +Include=video + +[mp4] +Regex=\.(mp4|m4v|mpe?g)$ +RegexIgnoreCase=true +Include=video + +# MPEG-2 TS container + H.264 codec +[mts] +Shell=.mts +ShellIgnoreCase=true +Include=video + +[ts] +Shell=.ts +ShellIgnoreCase=true +Include=video + +[bob] +Shell=.vob +ShellIgnoreCase=true +Include=video + +[wmv] +Shell=.wmv +ShellIgnoreCase=true +Include=video + +[fli] +Regex=\.fl[icv]$ +RegexIgnoreCase=true +Include=video + +[ogv] +Shell=.ogv +ShellIgnoreCase=true +Include=video + +[realaudio] +Regex=\.ra?m$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/video.sh open ram + +[webm-by-shell] +Shell=.webm +ShellIgnoreCase=true +Include=video + + +### Documents ### + +[html] +Regex=\.html?$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/web.sh open html +View=%view{ascii} /usr/lib/mc/ext.d/web.sh view html + +[StarOffice-5.2] +Shell=.sdw +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open ooffice + +# StarOffice 6 and OpenOffice.org formats +[OpenOffice.org] +Regex=\.(odt|fodt|ott|sxw|stw|ods|fods|ots|sxc|stc|odp|fodp|otp|sxi|sti|odg|fodg|otg|sxd|std|odb|odf|sxm|odm|sxg)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open ooffice +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view odt + +[AbiWord] +Shell=.abw +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open abw + +[Gnumeric] +Shell=.gnumeric +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open gnumeric + +[rtf] +Shell=.rtf +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open msdoc + +# Microsoft Word Document +[msdoc-by-shell] +Regex=\.(do[ct]|wri|docx)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open msdoc +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msdoc + +# Microsoft Excel Worksheet +[msxls-by-shell] +Regex=\.(xl[sw]|xlsx)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open msxls +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msxls + +# Microsoft PowerPoint Presentation +[msppt] +Regex=\.(pp[ts]|pptx)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open msppt +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msppt + +[dvi] +Shell=.dvi +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open dvi +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view dvi + +[tex] +Shell=.tex +ShellIgnoreCase=true +Include=editor + +[markdown] +Regex=\.(md|mkd)$ +ShellIgnoreCase=true +Include=editor + +[djvu] +Regex=\.djvu?$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open djvu +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view djvu + +# Comic Books +[cbr] +Regex=\.cb[zr]$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open comic + +# Epup, mobi, fb2 +[ebook] +Regex=\.(epub|mobi|fb2)$ +RegexIgnoreCase=true +Open=/usr/lib/mc/ext.d/doc.sh open ebook +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view ebook + + +### Miscellaneous ### + +# Compiled Java classes +[javaclass] +Shell=.class +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view javaclass + +[Imakefile] +Shell=Imakefile +Open=xmkmf -a + +# Makefile.PL (MakeMaker) +[Makefile.pl] +Regex=^Makefile\.(PL|pl)$ +Open=%var{PERL:perl} %f + +[Makefile] +Regex=^[Mm]akefile +Open=make -f %f %{Enter parameters} + +[dbf] +Shell=.dbf +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/misc.sh open dbf +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view dbf + +# REXX script +[rexx] +Regex=\.(rexx?|cmd)$ +Open=rexx %f %{Enter parameters};echo "Press ENTER";read y + +# Disk images for Commodore computers (VIC20, C64, C128) +[d64] +Shell=.d64 +ShellIgnoreCase=true +Open=%cd %p/uc1541:// +View=%view{ascii} c1541 %f -list + +# Glade, a user interface designer for GTK+ and GNOME +[glade] +Shell=.glade +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/misc.sh open glade + +# Gettext Catalogs +[mo] +Regex=.g?mo$ +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view mo + +[po] +Shell=.po +Open=/usr/lib/mc/ext.d/misc.sh open po + +[lyx] +Shell=.lyx +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/misc.sh open lyx +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view lyx + +[torrent] +Shell=.torrent +ShellIgnoreCase=true +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view torrent + + +### Plain compressed files ### + +[ace] +Shell=.ace +ShellIgnoreCase=true +Open=%cd %p/uace:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view ace + +[arc] +Shell=.arc +ShellIgnoreCase=true +Open=%cd %p/uarc:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view arc + +[zip-by-shell] +Shell=.zip +ShellIgnoreCase=true +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip + +[zoo] +Shell=.zoo +ShellIgnoreCase=true +Open=%cd %p/uzoo:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zoo + +[lz4] +Shell=.lz4 +ShellIgnoreCase=true +Open=/usr/lib/mc/ext.d/archive.sh view lz4 %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lz4 + +[wim] +Shell=.wim +ShellIgnoreCase=true +Open=%cd %p/uwim:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view wim + + +######### Files by Type ######### + +### Archives ### + +[mailbox] +Type=^ASCII\ mail\ text +Open=%cd %p/mailfs:// + + +### Sources ### + +# Object +[elf] +Type=^ELF +#Open=%var{PAGER:more} %f +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view elf + + +### Documentation ### + +# GNU Info page +[info-by-type] +Type=^Info\ text +Open=/usr/lib/mc/ext.d/text.sh open info + +# Manual page - compressed +[troff.gz] +Type=troff.*gzip compressed +Open=/usr/lib/mc/ext.d/text.sh open man.gz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.gz %var{PAGER:more} + +[troff.bzip] +Type=troff.*bzip compressed +Open=/usr/lib/mc/ext.d/text.sh open man.bz %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.bz %var{PAGER:more} + +[troff.bzip2] +Type=troff.*bzip2 compressed +Open=/usr/lib/mc/ext.d/text.sh open man.bz2 %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man.bz2 %var{PAGER:more} + +# Manual page +[man] +Type=troff or preprocessor input +Open=/usr/lib/mc/ext.d/text.sh open man %var{PAGER:more} +View=%view{ascii,nroff} /usr/lib/mc/ext.d/text.sh view man %var{PAGER:more} + + +### Images ### + +[gif] +Type=^GIF +Include=image + +[jpeg] +Type=^JPEG +Include=image + +[bitmap] +Type=^PC\ bitmap +Include=image + +[png] +Type=^PNG +Include=image + +[jng] +Type=^JNG +Include=image + +[mng] +Type=^MNG +Include=image + +[tiff] +Type=^TIFF +Include=image + +[rbm] +Type=^PBM +Include=image + +[pgm] +Type=^PGM +Include=image + +[ppm] +Type=^PPM +Include=image + +[netpbm] +Type=^Netpbm +Include=image + + +### Video ### + +[webm-by-type] +Type=WebM +Include=video + + +### Documents ### + +[postscript] +Type=^PostScript +Open=/usr/lib/mc/ext.d/doc.sh open ps +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view ps + +[pdf] +Type=^PDF +Open=/usr/lib/mc/ext.d/doc.sh open pdf +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view pdf + +# Microsoft Word Document +[msdoc-by-type] +Type=^Microsoft\ Word +Open=/usr/lib/mc/ext.d/doc.sh open msdoc +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msdoc + +# Microsoft Excel Worksheet +[msxls-by-type] +Type=^Microsoft\ Excel +Open=/usr/lib/mc/ext.d/doc.sh open msxls +View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msxls + +# Use OpenOffice.org/LibreOffice to open any MS Office documents +[mso-doc-1] +Type=^Microsoft\ Office\ Document +Open=/usr/lib/mc/ext.d/doc.sh open ooffice + +[mso-doc-2] +Type=^Microsoft\ OOXML +Open=/usr/lib/mc/ext.d/doc.sh open ooffice + +[framemaker] +Type=^FrameMaker +Open=/usr/lib/mc/ext.d/doc.sh open framemaker + + +### Miscellaneous ### + +[sqlite3.db] +Type=^SQLite 3.x database +Open=/usr/lib/mc/ext.d/misc.sh open sqlite +View=%view{ascii} /usr/lib/mc/ext.d/misc.sh view sqlite + + +### Plain compressed files ### + +[gzip] +Type=\(gzip compressed +Open=/usr/lib/mc/ext.d/archive.sh view gz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view gz + +[bzip] +Type=\(bzip compressed +Open=/usr/lib/mc/ext.d/archive.sh view bzip %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view bzip + +[bzip2] +Type=\(bzip2 compressed +Open=/usr/lib/mc/ext.d/archive.sh view bzip2 %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view bz2 + +[compress] +Type=\(compress'd +Open=/usr/lib/mc/ext.d/archive.sh view gz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view gz + +[lz] +Type=\(lzip compressed +Open=/usr/lib/mc/ext.d/archive.sh view lz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lz + +[lzma] +Type=\(LZMA compressed +Open=/usr/lib/mc/ext.d/archive.sh view lzma %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lzma + +[xz] +Type=\(XZ compressed +Open=/usr/lib/mc/ext.d/archive.sh view xz %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view xz + +[zstd] +Type=\(Zstandard compressed +Open=/usr/lib/mc/ext.d/archive.sh view zst %var{PAGER:more} +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zst + +[zip-by-type] +Type=\(Zip archive +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip + +[jar] +Type=\(Java\ (Jar\ file|archive)\ data\ \((zip|JAR)\) +TypeIgnoreCase=true +Open=%cd %p/uzip:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view zip + +[lha] +Type=^LHa\ .*archive +Open=%cd %p/ulha:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view lha + +[pak] +Type=^PAK\ .*archive +Open=%cd %p/unar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view pak + +# Parity Archive +[par2] +Type=^Parity\ Archive\ Volume\ Set +Open=/usr/lib/mc/ext.d/archive.sh open par2 + + +######### Includes ######### +# Includes should be at end of the bindings + +[Include/tar.gz] +Open=%cd %p/utar:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view tar.gz + +[Include/cpio] +Open=%cd %p/ucpio:// +View=%view{ascii} /usr/lib/mc/ext.d/archive.sh view cpio + +[Include/editor] +Open=%var{EDITOR:editor} %f + +[Include/image] +Open=/usr/lib/mc/ext.d/image.sh open ALL_FORMATS +View=%view{ascii} /usr/lib/mc/ext.d/image.sh view ALL_FORMATS + +[Include/video] +Open=/usr/lib/mc/ext.d/video.sh open ALL_FORMATS +View=%view{ascii} /usr/lib/mc/ext.d/video.sh view ALL_FORMATS + + +######### Default ######### + +# Default target for anything not described above +[Default] +Open= +View= + +### EOF ### diff --git a/.mc/menu b/.mc/menu index 3bc74d1..c2198c8 100644 --- a/.mc/menu +++ b/.mc/menu @@ -16,32 +16,36 @@ shell_patterns=0 $CMD "$f" done -+ t r ++ t lr p View the file in a pager exec ${PAGER:-more} %f -+ t r ++ t lr g Edit the file in gvim gvim %f & -+ t r ++ t lr b View the file in a browser - exec webbrowser file://%d/%f + exec webbrowser-encode-url -e utf-8 file://%d/%f -+ t r ++ t lr = f \.(htm(l?)|txt)$ w View the file in a new browser window - exec webbrowser -n file://%d/%f + exec webbrowser-encode-url -e utf-8 -n file://%d/%f -+ t r ++ t lr t View the file in a new browser tab - exec webbrowser -t file://%d/%f + exec webbrowser-encode-url -e utf-8 -t file://%d/%f -+= f \.fb2(\.bz2|\.gz|\.zip)?$ | f \.(chm|epub|htm(l?)|txt|rtf)$ & t r ++ t lr +p View the file in a new private browser tab + exec webbrowser -p file://%d/%f + ++= f \.fb2(\.bz2|\.gz|\.zip)?$ | f \.(chm|epub|htm(l?)|txt|rtf)$ & t lr f View fb2/chm/epub with fbreader fbreader %f & -+ t r & f \.fb2(\.bz2|\.gz|\.zip)$ ++ t lr & f \.fb2(\.bz2|\.gz|\.zip)$ H fb2html case %f in *.fb2.bz2) A="bunzip2 -c" ;; @@ -51,7 +55,7 @@ H fb2html esac $A %f | xsltproc /usr/local/src/FictionBook/FB2_2_html_ru.xsl - | webstdin -t -+ t r & f \.fb2(\.bz2|\.gz|\.zip)$ ++ t lr & f \.fb2(\.bz2|\.gz|\.zip)$ T fb2txt case %f in *.fb2.bz2) A="bunzip2 -c" ;; @@ -61,109 +65,135 @@ T fb2txt esac $A %f | xsltproc /usr/local/src/FictionBook/FB2_2_txt_ru.xsl - | webstdin -e txt -t -+= t r & f \.(pdf|PDF|ps|PS)(\.bz2|\.gz)?$ -e View pdf/ps - qpdfview %f & ++ t lr & f \.(pdf|PDF)$ +v View pdf + pdftotext -layout -q %f - | iconv.py -f utf-8 | ${PAGER:-more} + ++ t lr & f \.(pdf|PDF)$ +e View pdf with evince + evince %f & + ++= t lr & f \.(pdf|PDF)$ +e View pdf with qpdfview + if [ %d/%f = "`echo %d/%f | iconv -t utf-8`" ]; then qpdfview %f & else src=%d/%f; dest="$HOME/tmp/`echo $src | iconv -t koi8-r | koi2lat | sed 's!/!%!g'`"; ln -s "$src" "$dest" && qpdfview "$dest" & (sleep 3; exec rm -f "$dest") & fi -+= t r & f \.djvu(\.bz2|\.gz)?$ ++= t lr & f \.djvu(\.bz2|\.gz)?$ e View djvu djview %f & -+= t r & f \.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg)$ -o View OpenDoc with odt2txt - odt2txt %f | ${PAGER:-more} - -+ t r & f \.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg|doc|DOC|rtf|docx|DOCX|xls|XLS|xlsx|XLSX)$ ++ t lr & f \.((pdf|PDF|ps|PS)(\.bz2|\.gz)?|odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg|doc|DOC|rtf|docx|DOCX|xls|XLS|xlsx|XLSX)$ e Edit (Open)Docs with libreoffice libreoffice %f & -+= t r & f \.(doc|DOC|rtf)$ ++ t lr & f \.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg|doc|DOC|rtf|docx|DOCX|xls|XLS|xlsx|XLSX)$ +v View (Open)Docs with libreoffice + #libreoffice --headless --convert-to "txt:Text (encoded):UTF8" %f + libreoffice --cat %f | ${PAGER:-more} + ++= t lr & f \.(doc|DOC|rtf)$ d View doc with catdoc catdoc %f | ${PAGER:-more} -+= t r & f \.(docx|DOCX)$ ++= t lr & f \.(odt|ott|sxw|stw|ods|ots|sxc|stc|odp|otp|sxi|sti|odg|otg|sxd|std|odb|odf|sxm|odm|sxg)$ +o View OpenDoc with odt2txt + odt2txt %f | ${PAGER:-more} + ++= t lr & f \.(docx|DOCX)$ d View docx with docx2txt docx2txt %f - | iconv.py -f utf-8 | ${PAGER:-more} -+= t r & f \.(xls|XLS)$ ++= t lr & f \.(xls|XLS|xlsx|XLSX)$ +o View OpenXlsx with xlsx2csv + xlsx2csv %f | iconv.py -f utf-8 | ${PAGER:-more} + ++= t lr & f \.(xls|XLS)$ x View xls with xls2csv xls2csv %f | ${PAGER:-more} -+ t r & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ | t t -= t r & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ ++ t lr & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm|ico|jp2|tif|TIF|tiff|TIFF|webp)$ | t t +e Edit image(s) + gimp %s & + ++ t lr & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ | t t += t lr & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ i View image(s) scaled - xli -title "`echo %s | sed 's/ /_/g'`" -zoom auto %s & + xli -title "`echo %s | sed 's/[ .]/_/g'`" -zoom auto %s & -+ t r & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ | t t ++ t lr & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ | t t I View image(s) full size - xli -title "`echo %s | sed 's/ /_/g'`" %s & + xli -title "`echo %s | sed 's/[ .]/_/g'`" %s & -+ t r & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ ++ t lr & f \.(bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|pbm|PBM|ppm|PPM|png|PNG|xbm|xpm)$ I Identify image xli -identify %f -+ t r & f \.(ico|jp2|tif|TIF|tiff|TIFF|webp)$ | t t -= t r & f \.(ico|jp2|tif|TIF|tiff|TIFF|webp)$ ++ t lr & f \.(ico|jp2|tif|TIF|tiff|TIFF|webp)$ | t t += t lr & f \.(ico|jp2|tif|TIF|tiff|TIFF|webp)$ I View icon, JPEG-2000, TIFF, WebP image display %s & -+ t r & f \.(aac|ac3|ape|cue|dts|flac|m3u|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ | t t ++ t lr & f \.(ico|jp2|tif|TIF|tiff|TIFF|webp)$ +I Identify image + identify %f + ++ t lr & f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ | t t a Add the audiofile(s) or playlist(s) - #if [ "`audtool --get-volume`" -eq 0 ]; then cgmem_nice 500 audacious & sleep 3; fi + #if [ "`audtool --get-volume`" -eq 0 ]; then audacious & sleep 3; fi #for f in %s; do - # audtool --playlist-addurl "$f" + # case "$f" in + # *.m3u8?) while read song; do + # audtool --playlist-addurl "$song" + # done < "$f" ;; + # *) audtool --playlist-addurl "$f" ;; + # esac #done - #smplay -add-to-playlist %s & deadbeef --queue %s & -+ t r & f \.(aac|ac3|ape|cue|dts|flac|m3u|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ | t t -= t r & f \.(aac|ac3|ape|cue|dts|flac|m3u|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ ++ t lr & f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ | t t += t lr & f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ p Load the audiofile(s) or playlist(s) - #if [ "`audtool --get-volume`" -eq 0 ]; then cgmem_nice 500 audacious & sleep 3; fi + #if [ "`audtool --get-volume`" -eq 0 ]; then audacious & sleep 3; fi #audtool --playlist-clear #for f in %s; do - # audtool --playlist-addurl "$f" + # case "$f" in + # *.m3u8?) while read song; do + # audtool --playlist-addurl "$song" + # done < "$f" ;; + # *) audtool --playlist-addurl "$f" ;; + # esac #done - #smplayer -send-action pl_remove_all - #smplay -add-to-playlist %s & - deadbeef --queue %s & + deadbeef %s & (sleep 1; exec deadbeef --stop) -+ t r & f \.(aac|ac3|ape|cue|dts|flac|m3u|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ | t t ++ t lr & f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mka|mp3|MP3|ogg|OGG|pls|WAV|wav|wv)$ | t t P Play the audiofile(s) or playlist(s) - #if [ "`audtool --get-volume`" -eq 0 ]; then cgmem_nice 500 audacious & sleep 3; fi + #if [ "`audtool --get-volume`" -eq 0 ]; then audacious & sleep 3; fi #audtool --playlist-clear #for f in %s; do - # audtool --playlist-addurl "$f" + # case "$f" in + # *.m3u8?) while read song; do + # audtool --playlist-addurl "$song" + # done < "$f" ;; + # *) audtool --playlist-addurl "$f" ;; + # esac #done #exec audtool --playback-play - #mplay -playlist %f & - #smplay %s & deadbeef %s & - #exec mediaplayer_open %f + #mplayer -playlist %f & -+ t r & f \.m3u ++ t lr & f \.m3u8? R Play the playlist in random order - "$HOME"/admin/prog/audio-cdr-video/audio/shuffle-playlist.py %f random-playlist-tmp.m3u - #if [ "`audtool --get-volume`" -eq 0 ]; then cgmem_nice 500 audacious & sleep 3; fi + "$HOME"/prog/audio-cdr-video/audio/shuffle-playlist.py %f /tmp/random-playlist-tmp.m3u + #if [ "`audtool --get-volume`" -eq 0 ]; then audacious & sleep 3; fi #audtool --playlist-clear - #audtool --playlist-addurl random-playlist-tmp.m3u + #while read song; do + # audtool --playlist-addurl "$song" + #done < /tmp/random-playlist-tmp.m3u #audtool --playback-play - #mplay -playlist random-playlist-tmp.m3u & - #smplay random-playlist-tmp.m3u & - #smplay -actions pl_shuffle %f & - deadbeef --queue random-playlist-tmp.m3u & deadbeef --play - #mediaplayer_open random-playlist-tmp.m3u - (sleep 5; exec rm random-playlist-tmp.m3u) & + deadbeef /tmp/random-playlist-tmp.m3u & + #mplayer -playlist /tmp/random-playlist-tmp.m3u & + (sleep 5; exec rm /tmp/random-playlist-tmp.m3u) & -+ f \.(aac|ac3|ape|cue|dts|flac|m3u|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t -s Play audio/video file(s) or directory with smplayer - smplay %s & - -+ t d & f (video_ts|VIDEO_TS)$ -c Play the current directory with smplayer - smplay . & - -+ t r & f \.(m3u|mp3|MP3|cue|aac|ac3|ape|dts|flac|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ ++ t lr & f \.(m3u8?|mp3|MP3|cue|aac|ac3|ape|dts|flac|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ i Audio/video info exec "$HOME"/.config/mpv/mpv_identify.sh %f @@ -171,46 +201,64 @@ i Audio/video info i DVD info exec "$HOME"/.config/mpv/mpv_identify.sh . -+ f \.(aac|ac3|ape|cue|dts|flac|m3u|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t -= f \.(aac|ac3|ape|cue|dts|flac|m3u|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ -m Play video file(s) with mpv - mplay %s & - -+ f \.(aac|ac3|ape|cue|dts|flac|m3u|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t -= f \.(aac|ac3|ape|cue|dts|flac|m3u|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ -m Play video file(s) with mpv asking audio volume ++ f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t +m Play video file(s) with mpv (quiet) + AUDIO_VOLUME=80 + export AUDIO_VOLUME + mplayer %s & + ++ f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t +m Play video file(s) with mpv (normal) + mplayer %s & + ++ f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t += f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ +m Play video file(s) with mpv (loud) + AUDIO_VOLUME=120 + export AUDIO_VOLUME + mplayer %s & + ++ f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t +m Play video file(s) with mpv (louder) + AUDIO_VOLUME=150 + export AUDIO_VOLUME + mplayer %s & + ++ f \.(aac|ac3|ape|cue|dts|flac|m3u8?|mp3|MP3|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|iso|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t d | t t +m Play video file(s) with mpv (ask for volume) AUDIO_VOLUME=%{Enter volume} - AUDIO_VOLUME=$AUDIO_VOLUME mplay %s & + export AUDIO_VOLUME + mplayer %s & -+ f \.(m3u|mp3|MP3|cue|aac|ac3|ape|dts|flac|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t t ++ f \.(m3u8?|mp3|MP3|cue|aac|ac3|ape|dts|flac|ogg|OGG|pls|WAV|wav|wv|avi|AVI|flv|m2ts|m4v|mka|mkv|MKV|mov|MOV|mp4|MP4|mpg|MPG|vob|VOB|wma|wmv)$ | t t M Play audio/video with mpv GUI - gmplay %s & + gmplayer %s & += t d & f (video_ts|VIDEO_TS)$ d Play DVD directory with mpv - mplay -dvd-device . dvd:// & + mplayer -dvd-device . dvd:// & + t d & f (video_ts|VIDEO_TS)$ D Play DVD directory with mpv GUI - gmplay -dvd-device . dvd:// & + gmplayer -dvd-device . dvd:// & + t d & f (video_ts|VIDEO_TS)$ t Play DVD title with mpv title=%{Enter title} - mplay -dvd-device . dvd://"$title" & + mplayer -dvd-device . dvd://"$title" & + t d & f (video_ts|VIDEO_TS)$ T Play DVD title with mpv GUI title=%{Enter title} - gmplay -dvd-device . dvd://"$title" & + gmplayer -dvd-device . dvd://"$title" & + t d p Play directory with mpv - mplay %f/* & + mplayer %f/* & + t d P Play directory with mpv GUI - gmplay %f/* & + gmplayer %f/* & + t d & f ^\.\.$ b Compress the current subdirectory to tar.bz2 @@ -284,35 +332,35 @@ y Compress the current subdirectory to zip recoding filenames cd .. && 7zr a "$ar".7z "$Pwd" && echo ../"$ar".7z created. -+ ! f \.(bz2|gz|lz|lzma|7z|xz|zip|ZIP)$ & t r ++ ! f \.(bz2|gz|lz|lzma|7z|xz|zip|ZIP)$ & t lr z bzip2 the file exec bzip2 -9 %f -+ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr z gzip the file exec gzip -9 %f -+ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr z lzip the file exec lzip -9 %f -+ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr z lzma the file exec lzma -9 %f -+ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr z 7z the file/directory exec 7zr a %f.7z %f -+ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr z xz the file exec xz -9 %f -+ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ ! 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 -+ ! f \.(z|Z|bz2|gz|lz|lzma)|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ ! 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) exec zip.py %f.zip %f @@ -326,7 +374,7 @@ Y zip selected files/directories recoding filenames ZIP=%{Enter zip name} exec zip.py "$ZIP" %s -+ f \.(tar\.(z|Z|bz2|gz|lz|lzma))|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t r ++ f \.(tar\.(z|Z|bz2|gz|lz|lzma))|(tbz2|tgz|tz|zip|ZIP|rar|RAR|xz|7z)$ & t lr n Create a directory for this archive case %f in *.tar.Z) D="`basename %f .tar.Z`";; @@ -368,7 +416,7 @@ N Create a directory for the other archive esac exec mkdir "$D" -+ f \.(tar\.(z|Z|bz2|gz|lz|lzma|7z|xz))|(tbz2|tgz|tz)$ & t r ++ f \.(tar\.(z|Z|bz2|gz|lz|lzma|7z|xz))|(tbz2|tgz|tz)$ & t lr x Extract the contents of a compressed tar file unset PRG case %f in @@ -424,7 +472,7 @@ X Extract the contents of an other compressed tar file esac $PRG %D/%F | tar xvpf - -+ f \.(bz2|egg|gz|lz|lzma|7z|xz|tar|whl|zip|ZIP|rar|RAR)$ & t r ++ f \.(bz2|egg|gz|lz|lzma|7z|xz|tar|whl|zip|ZIP|rar|RAR)$ & t lr x Extract a compressed file case %f in *.bz2) P="bzip2 -d";; @@ -454,7 +502,7 @@ X Extract another compressed file esac exec $P %D/%F -+ t r & f \.(zip|ZIP)$ ++ t lr & f \.(zip|ZIP)$ y Extract from zip recoding filenames exec unzip.py %f @@ -462,31 +510,31 @@ y Extract from zip recoding filenames Y Extract from other zip recoding filenames exec unzip.py %D/%F -+ t r ++ t lr v View via mailcap exec see %f -+ t r ++ t lr c Compare the file exec cmp %D/%f %f -+ t r & T r ++ t lr & T r C Compare these files exec cmp %D/%F %f -+ t r ++ t lr d Diff the file exec diff -u --speed-large-files %D/%f %f -+ t r & T r ++ t lr & T r D Diff these files exec diff -u --speed-large-files %D/%F %f -+ t r ++ t lr v vimdiff the file exec vim -d %D/%f %f -+ t r & T r ++ t lr & T r V vimdiff these files exec vim -d %D/%F %f @@ -500,11 +548,15 @@ D Diff these directories exec diff -ru --speed-large-files \ -x CVS -x .git -x .hg -x .svn -x '*.py[co]' -x __pycache__ %D/%F %f -+= f \.(asc|sig(n)?)$ & t r ++= f \.(asc|gpg|sig(n)?)$ & t lr v Verify signature exec gpg --verify %f -+= f \.[1-8]$ | f \.man$ & t r ++ f \.(asc|gpg|sig(n)?)$ & t lr +v Verify detached signature + exec gpg --verify %f "`echo %f | sed 's/\.[^.]*$//'`" + ++= f \.[1-8]$ | f \.man$ & t lr 1 Display the file with roff -man %view nroff -man %f @@ -512,6 +564,6 @@ m View a manual page MAN=%{Enter manual name} %view man -P cat $MAN -+ t r | t d | t t ++ t dlr | t t r rsync the file(s) there rsync -ahPv --del %s %D diff --git a/.muttrc b/.muttrc index 5b82939..b347d4f 100644 --- a/.muttrc +++ b/.muttrc @@ -299,6 +299,25 @@ bind index,pager S decode-save # Macros # +# KP_Enter -> Enter +#macro generic,pager,editor +# KP_Home -> Home +macro generic,pager,editor +# KP_Up -> Up +macro generic,pager,editor \1074 +# KP_Next -> PageUp +macro generic,pager,editor +# KP_Left -> Left +macro generic,pager,editor \1075 +# KP_Right -> Right +macro generic,pager,editor \1076 +# KP_End -> End +macro generic,pager,editor +# KP_Down -> Down +macro generic,pager,editor \1077 +# KP_Prev -> PageDown +macro generic,pager,editor + macro index C \ \ "Go to the first folder with unread messages" @@ -310,10 +329,10 @@ macro index,pager S \ ! \ "Move current message to inbox" -macro index,pager h \ +macro index,pager,attach h \ ":auto_view text/html" \ "View HTML attachments" -macro index,pager H \ +macro index,pager,attach H \ ":unauto_view text/html" \ "Don't show HTML attachments" @@ -343,6 +362,14 @@ macro pager,attach M \ =sent-mail \ "Go to sent-mail" +macro index,pager \cV "" \ + "Show version" + +macro index,pager V "v/text/htmlV" \ + "View the 1st html attachment in a web browser" +macro attach V "~/tmp/_xxx.htmlnwebbrowser -n ~/tmp/_xxx.html; exec rm ~/tmp/_xxx.html" \ + "View html attachment in a web browser" + # Go to python mailbox macro index Y \ =lists/python \ @@ -351,20 +378,6 @@ macro pager,attach Y \ =lists/python \ "Go to python" -# Go to STCnet "Atlas"/STM mailboxes -macro index \ca \ - =stcnet \ - "Go to stcnet inbox" -macro pager,attach \ca \ - =stcnet \ - "Go to stcnet inbox" -macro index A \ - =sent-stcnet \ - "Go to sent-stcnet" -macro pager,attach A \ - =sent-stcnet \ - "Go to sent-stcnet" - # Recode base64 to 8bit, html to plain text, mustdie-1251 to koi8-r, etc. macro index,pager \ m "mimedecode | less" \ diff --git a/.plan b/.plan index 50b2d83..2bce39f 100644 --- a/.plan +++ b/.plan @@ -1,8 +1,9 @@ Home page: https://phdru.name/ e-mail: phd@phdru.name, phd@mail.ru -Jabber: phd@phdru.name, phd@jabber.ru +Jabber: phd@jabber.ru SIP: phd@iptel.org, phd@sipnet.ru ICQ: 39288223 -mobile phone: +7 (905) 704-20-85 +mobile phone: +7 (905) 704-20-85 (Viber, WhatsApp) +Skype: phd_at_mail.ru GPG key id: 0x6E080B70B6287B03 GPG fingerprint: 0179 A9FA FE7B EB77 06FC E328 6E08 0B70 B628 7B03 diff --git a/.procmailrc b/.procmailrc index a5e970c..e132872 100644 --- a/.procmailrc +++ b/.procmailrc @@ -139,6 +139,12 @@ lists/python * ^List-Id: .* lists/python +:0 +* ^From: .+ +* ^To: CheetahTemplate3/cheetah3 +* ^List-ID: CheetahTemplate3/cheetah3 +lists/python + :0 * ^Sender: ppa-qps-devel-admin@lists\.sourceforge\.net lists/python diff --git a/.profile b/.profile index f222e80..45b4a56 100644 --- a/.profile +++ b/.profile @@ -8,13 +8,8 @@ # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package. -if test -n "$BASH_VERSION"; then - case "$SHELL" in - */bash) ;; - */*csh) SHELL=/bin/bash ;; - # this is for bash.exe - *command.com | *\\bash) SHELL=//c/ubin/bash ;; - esac +#if test -n "$BASH_VERSION"; then +# bash #elif test -n "$KSH_VERSION"; then # ksh93 #elif test -n "$FCEDIT"; then @@ -25,10 +20,10 @@ if test -n "$BASH_VERSION"; then # unknown #else # sh -fi +#fi if [ -z "$USER" ]; then - USER="$LOGNAME"; export USER + USER="$LOGNAME"; export USER fi # the default umask is set in /etc/profile; for setting the umask @@ -39,7 +34,7 @@ fi ### umask 022 is less restrictive, 077 more paranoid umask 077 -PATH="$HOME"/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +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 # LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib export PATH MANPATH # LD_LIBRARY_PATH @@ -47,11 +42,11 @@ export PATH MANPATH # LD_LIBRARY_PATH LANG=C #LC_ALL=C case "$LC_CTYPE" in - *UTF-8) # LC_CTYPE is already set - ;; + *UTF-8) # LC_CTYPE is already set + ;; - *) LC_CTYPE=ru_RU.KOI8-R - ;; + *) LC_CTYPE=ru_RU.KOI8-R + ;; esac LC_COLLATE="$LC_CTYPE" #LANGUAGE="ru en" @@ -74,161 +69,147 @@ export ORGANIZATION # NNTPSERVER # Interactive only commands if [ -t 0 ] ; then - if [ -z "$TERM" ]; then - eval `tset -Q -s -m 'network:?xterm'` - fi - - stty sane erase ^H - - if [ -n "`which less 2>/dev/null`" ]; then - HAS_LESS=true - fi - - case "$TERM" in - linux) - # mutt, python and vim - BACKGROUND=DARK - export BACKGROUND - [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/dark_bg - ;; - - *rxvt*|screen*|*term*|vt100) - BACKGROUND=LIGHT - export BACKGROUND - [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/light_bg - ;; - esac - - if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - fi - - if [ -n "$HAS_LESS" ]; then - PAGER=less - LESS="Rgimq" - case "$LC_CTYPE" in - *UTF-8) LESSCHARSET=utf-8 - ;; - - *) LESSCHARSET=koi8-r - ;; - esac - #LESSCHARDEF=32c. - LESSEDIT='vim ?lt+%lt. -- %f' - export LESS LESSCHARSET LESSEDIT # LESSCHARDEF - - # make less more friendly for non-text input files, see lesspipe(1) - #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - - else - PAGER=more - fi - export PAGER - - EDITOR="$HOME"/.vim/vim.sh - FCEDIT="$EDITOR" - VISUAL="$EDITOR" - export EDITOR FCEDIT VISUAL - - HISTCONTROL=ignoreboth - HISTIGNORE='&: *:x:X:[bf]g' - HISTFILE="$HOME/.sh_history" - HISTFILESIZE=2000 - HISTSIZE=1000 - export HISTCONTROL HISTIGNORE HISTFILE HISTFILESIZE HISTSIZE - - # Used by bash/mc for hostname completion - HOSTFILE="$HOME"/lib/config/hosts - export HOSTFILE - - MAIL="/var/mail/$USER" - MAILPATH="$MAIL:$HOME/mail/admin:$HOME/mail/block:$HOME/mail/bulk" - if [ -d "$HOME"/mail/lists/ ]; then - MAILPATH="$MAILPATH:`echo $HOME/mail/lists/* | sed 's/ /:/g'`" - fi - export MAIL MAILPATH - - BROWSER="links2:links:elinks:w3m:lynx" - case "$TERM" in - *rxvt*|screen*|*term*|vt100) - BROWSER="l:$BROWSER" - ;; - esac - export BROWSER - - #all_proxy="http://localhost:3128" - #ftp_proxy="$all_proxy" - #gopher_proxy="$all_proxy" - #http_proxy="$all_proxy" - #https_proxy="$all_proxy" - auto_proxy="file:///home/phd/admin/WWW/Mozilla/mozilla.pac" - no_proxy="localhost,127.0.0.1" - #export all_proxy ftp_proxy http_proxy https_proxy auto_proxy no_proxy # gopher_proxy - export auto_proxy no_proxy - - ENV="$HOME/.shellrc" - export ENV - - # set variable identifying the chroot you work in (used in the prompt below) - if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot="`cat /etc/debian_chroot`" - fi - - if test -n "$BASH_VERSION"; then - # display the user, host and current working directory - # in the terminal title - case "$TERM" in - *rxvt*|screen*|*term*|vt100) - OPS1="\[\033]0;${debian_chroot:+($debian_chroot)}\u@\h:\w\007\]" - case "$TERM" in - screen*) - OPS1=${OPS1}"\[\033k${debian_chroot:+($debian_chroot)}\u@\h:\w\033\\\\\]" # Set screen/tmux caption - ;; - esac - ;; - - *) - OPS1="" - ;; - esac - - OPS1=${OPS1}"${debian_chroot:+($debian_chroot)}\u@\h \W " - . "$ENV" - - else - OPS1="${debian_chroot:+($debian_chroot)}`/usr/bin/whoami`@`/bin/hostname -s` " - fi - - #PROMPT_DIRTRIM=2 - export OPS1 # PROMPT_DIRTRIM - - ### biff controls new mail notification - #biff n - ### mesg controls messages (write/talk) from other users - mesg n - # make mail(1) use a pager - crt=; export crt - - PYTHONSTARTUP="$HOME"/lib/python/init.py - export PYTHONSTARTUP - - name="Oleg Broytman" - email="phd@phdru.name" - - GIT_AUTHOR_NAME="$name" - GIT_AUTHOR_EMAIL="$email" - GIT_COMMITTER_NAME="$name" - GIT_COMMITTER_EMAIL="$email" - export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL - - HGUSER="$name <$email>" - export HGUSER - - unset name email - - #if test -f .hushlogin && ! cmp -s .motd /etc/motd; then - # tee $HOME/.motd < /etc/motd - #fi + #if test -f .hushlogin && ! cmp -s .motd /etc/motd; then + # tee $HOME/.motd < /etc/motd + #fi + + if [ -z "$TERM" ]; then + eval `tset -Q -s -m 'network:?xterm'` + fi + + stty sane erase ^H + + if which less >/dev/null 2>&1; then + HAS_LESS=true + fi + + case "$TERM" in + linux) + # mutt, python and vim + BACKGROUND=DARK + export BACKGROUND + [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/dark_bg + ;; + + *rxvt*|screen*|*term*|vt100) + BACKGROUND=LIGHT + export BACKGROUND + [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/light_bg + ;; + esac + + if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + fi + + if [ -n "$HAS_LESS" ]; then + PAGER=less + LESS="Rgimq" + case "$LC_CTYPE" in + *UTF-8) LESSCHARSET=utf-8 + ;; + + *) LESSCHARSET=koi8-r + ;; + esac + #LESSCHARDEF=32c. + LESSEDIT='vim ?lt+%lt. -- %f' + export LESS LESSCHARSET LESSEDIT # LESSCHARDEF + + # make less more friendly for non-text input files, see lesspipe(1) + #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + + else + PAGER=more + fi + export PAGER + + EDITOR="$HOME"/.vim/vim.sh + FCEDIT="$EDITOR" + 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`" + HISTFILE="$HOME/.sh_history" + HISTFILESIZE=2000 + HISTSIZE=1000 + export HISTCONTROL HISTIGNORE HISTFILE HISTFILESIZE HISTSIZE + + # Used by bash/mc for hostname completion + HOSTFILE="$HOME"/lib/config/hosts + export HOSTFILE + + MAIL="/var/mail/$USER" + MAILPATH="$MAIL:$HOME/mail/admin:$HOME/mail/block:$HOME/mail/bulk" + if [ -d "$HOME"/mail/lists/ ]; then + MAILPATH="$MAILPATH:`echo $HOME/mail/lists/* | sed 's/ /:/g'`" + fi + export MAIL MAILPATH + if [ -n "$STY" -a "$WINDOW" != 0 ]; then + unset MAILCHECK + fi + + BROWSER="links2:links:elinks:w3m:lynx" + case "$TERM" in + *rxvt*|screen*|*term*|vt100) + BROWSER="l:$BROWSER" + ;; + esac + export BROWSER + + #all_proxy="http://localhost:3128" + #ftp_proxy="$all_proxy" + #gopher_proxy="$all_proxy" + #http_proxy="$all_proxy" + #https_proxy="$all_proxy" + auto_proxy="file:///home/phd/admin/WWW/Mozilla/mozilla.pac" + no_proxy="localhost,127.0.0.1" + #export all_proxy ftp_proxy http_proxy https_proxy auto_proxy no_proxy # gopher_proxy + export auto_proxy no_proxy + + ENV="$HOME/.shellrc" + export ENV + + # set variable identifying the chroot you work in (used in the prompt below) + if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot="`cat /etc/debian_chroot`" + fi + + if test -n "$BASH_VERSION"; then + . "$HOME/.bashrc" + else + PS1="${debian_chroot:+($debian_chroot)}`/usr/bin/whoami`@`/bin/hostname -s` > " + fi + + ### biff controls new mail notification + #biff n + ### mesg controls messages (write/talk) from other users + mesg n + # make mail(1) use a pager + crt=; export crt + + PYTHONSTARTUP="$HOME"/lib/python/init.py + export PYTHONSTARTUP + + name="Oleg Broytman" + email="phd@phdru.name" + + GIT_AUTHOR_NAME="$name" + GIT_AUTHOR_EMAIL="$email" + GIT_COMMITTER_NAME="$name" + GIT_COMMITTER_EMAIL="$email" + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL + + HGUSER="$name <$email>" + export HGUSER + + unset name email + + #SCREENDIR="$HOME"/tmp/screen + #export SCREENDIR + #mkdir -p "$SCREENDIR" + #chmod 700 "$SCREENDIR" fi # No need to set DISPLAY - ssh sets DISPLAY and calls xauth @@ -236,39 +217,41 @@ fi #export DISPLAY if [ -n "$DISPLAY" ]; then - # mutt, python and vim - BACKGROUND=LIGHT - export BACKGROUND - [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/light_bg - - # BROWSERs - BROWSER="firefox:seamonkey:chromium:google-chrome:opera:xlinks2:$BROWSER" - - ### X Window System Configuration - #XAPPLRESDIR="$HOME/lib/X11/app-defaults/"; export XAPPLRESDIR - ### Old-style XNLSPATH - #XNLSPATH=/usr/X11R6/lib/X11/nls; export XNLSPATH - - # For GTK2/GLib to convert filenames between internal and locale encodings - G_FILENAME_ENCODING="@locale" - export G_FILENAME_ENCODING - #G_BROKEN_FILENAMES=1 - #export G_BROKEN_FILENAMES - - # X Input Method, for Multi key (Compose) to work - GTK_IM_MODULE=xim - QT_IM_MODULE=xim - export GTK_IM_MODULE QT_IM_MODULE - - # GTK2 anti-aliasing - GDK_USE_XFT=1 - export GDK_USE_XFT - - # nVidia OpenGL full scene anti-aliasing - #__GL_FSAA_MODE=4 - #export __GL_FSAA_MODE - - #xhost +local:root > /dev/null 2>&1 + PATH=$PATH:/usr/games + + # mutt, python and vim + BACKGROUND=LIGHT + export BACKGROUND + [ -n "$HAS_LESS" ] && . "$HOME"/lib/config/less/light_bg + + # BROWSERs + BROWSER="firefox:seamonkey:chromium:google-chrome:opera:xlinks2:$BROWSER" + + ### X Window System Configuration + #XAPPLRESDIR="$HOME/lib/X11/app-defaults/"; export XAPPLRESDIR + ### Old-style XNLSPATH + #XNLSPATH=/usr/X11R6/lib/X11/nls; export XNLSPATH + + # For GTK2/GLib to convert filenames between internal and locale encodings + G_FILENAME_ENCODING="@locale" + export G_FILENAME_ENCODING + #G_BROKEN_FILENAMES=1 + #export G_BROKEN_FILENAMES + + # X Input Method, for Multi key (Compose) to work + GTK_IM_MODULE=xim + QT_IM_MODULE=xim + export GTK_IM_MODULE QT_IM_MODULE + + # GTK2 anti-aliasing + GDK_USE_XFT=1 + export GDK_USE_XFT + + # nVidia OpenGL full scene anti-aliasing + #__GL_FSAA_MODE=4 + #export __GL_FSAA_MODE + + #xhost +local:root > /dev/null 2>&1 fi [ -n "$HAS_LESS" ] && unset HAS_LESS @@ -286,11 +269,11 @@ fi # If SUN console, start the windows system # # if [ `tty` = /dev/console ] ; then -# if [ "$TERM" = sun -o "$TERM" = AT386 ] ; then +# if [ "$TERM" = sun -o "$TERM" = AT386 ] ; then # # if [ ${OPENWINHOME:-""} = "" ] ; then -# OPENWINHOME=/usr/openwin -# export OPENWINHOME +# OPENWINHOME=/usr/openwin +# export OPENWINHOME # fi # # echo "" @@ -299,8 +282,8 @@ fi # # "$OPENWINHOME"/bin/openwin # -# clear # get rid of annoying cursor rectangle -# #exit # logout after leaving windows system +# clear # get rid of annoying cursor rectangle +# #exit # logout after leaving windows system # -# fi +# fi # fi diff --git a/.project b/.project index ad85a06..88ded7d 100644 --- a/.project +++ b/.project @@ -1,2 +1 @@ Programmer at STCnet "Atlas"/SmartTeleMax. -Programmer/sysadmin at NRSC - https://oper.med.ru/ . diff --git a/.psqlrc b/.psqlrc index 0b25277..479514d 100644 --- a/.psqlrc +++ b/.psqlrc @@ -6,6 +6,7 @@ \set HISTCONTROL ignoreboth \set HISTSIZE 1000 \set ON_ERROR_ROLLBACK interactive +\set ON_ERROR_STOP on \set PROMPT1 '%m %n@%/ %R%# ' \set PROMPT2 '... %R ' \set PROMPT3 '>> ' diff --git a/.screenrc b/.screenrc index 1b17439..a085862 100644 --- a/.screenrc +++ b/.screenrc @@ -13,6 +13,11 @@ startup_message off deflogin on shell -$SHELL +# For this to work PS1 prompt must include empty "k\" sequence +# and ends with "$ ". +#shelltitle "\$ |$SHELL" +#bind R screen -t '# |root:' sudo su - + # define a bigger scrollback, default is 100 lines defscrollback 1024 @@ -36,6 +41,34 @@ bind ^\ # on backspace send ^H #bindkey -d -k kb stuff "\010" +# Remap keypad +#KP_Home +bindkey \033Ow stuff \033[1~ +#KP_Up +bindkey \033Ox stuff \033OA +#KP_PgUp +bindkey \033Oy stuff \033[5~ +#KP_Left +bindkey \033Ot stuff \033OD +#KP_Right +bindkey \033Ov stuff \033OC +#KP_End +bindkey \033Oq stuff \033[4~ +#KP_Down +bindkey \033Or stuff \033OB +#KP_PgDn +bindkey \033Os stuff \033[6~ +#KP_minus +bindkey \033Om stuff - +#KP_plus +bindkey \033Ok stuff + +#KP_slash +bindkey \033Oo stuff / +#KP_asterisk +bindkey \033Oj stuff * +#KP_Enter +bindkey \033OM stuff \015 + # ------------------------------------------------------------------------------ # TERMINAL SETTINGS # ------------------------------------------------------------------------------ @@ -57,11 +90,13 @@ termcapinfo xterm*|rxvt*|kterm*|Eterm* hs:ts=\E]0;:fs=\007:ds=\E]0;\007 #hardstatus lastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<" # status line at the bottom of terminal -# display numbers and titles: -# for inactive windows - black on cyan -# for active window - white on blue -hardstatus alwayslastline -hardstatus string "%{= ck}%-w%{= bw}%n%f %t%{-}%+w %-=" +# display window number, flags and title +# for inactive windows - black on yellow (brown) +# for active window - black on green +#hardstatus alwayslastline +#hardstatus string "%{= yk}%-w%{= gk}%n%f %t%{-}%+w %-=" + +caption always "%{= yk}%-w%{= gk}%n%f %t%{-}%+w %-=" # set these terminals up to be 'optimal' instead of vt100 termcapinfo xterm*|rxvt*|linux*|Eterm* OP @@ -83,7 +118,7 @@ termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l' #termcapinfo rxvt* 'ti=\E7\E[?47h:te=\E[2J\E[?47l\E8' # Do not use the alternate screen at all -# run `tput smcup; screen -S test; tput rmcup` +# run `tput smcup; screen; tput rmcup` termcapinfo xterm*|rxvt* 'ti=:te=' # Enable non-blocking mode to better cope with flaky ssh connections. diff --git a/.shellrc b/.shellrc index 5200b80..9f9242a 100644 --- a/.shellrc +++ b/.shellrc @@ -2,10 +2,6 @@ # $HOME/.shellrc # -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - # If not running interactively, don't do anything case $- in *i*) ;; @@ -15,20 +11,6 @@ esac # Stop if non-interactive shell [ -z "$PS1" ] && return -if test -n "$BASH_VERSION"; then - # append to the history file, don't overwrite it - shopt -s histappend - - # check the window size after each command and, if necessary, - # update the values of LINES and COLUMNS. - shopt -s checkwinsize - - # If set, the pattern "**" used in a pathname expansion context will - # match all files and zero or more directories and subdirectories. - #shopt -s globstar -fi - - #if [ -x /usr/bin/dircolors ]; then # # I don't like these aliases - they work only in command line # # but not in scripts I run from command line. @@ -47,393 +29,184 @@ fi case "$HOME" in - /home/*) - if [ -L /home ]; then - START_DIR="`pwd`" && - cd "$HOME" && - HOME="`pwd`" && - cd "$START_DIR" - fi - ;; + /home/*) + if [ -L /home ]; then + START_DIR="`pwd`" && + cd "$HOME" && + HOME="`pwd`" && + cd "$START_DIR" + fi + ;; esac - -OPS1="$OPS1\\$" -PS1="$OPS1 " - - -if test -n "$BASH_VERSION"; then - [ "`type -t ls`" = alias ] && unalias ls - [ "`type -t ll`" = alias ] && unalias ll - [ "`type -t mc`" = alias ] && unalias mc - - back() { cd - "$@"; } - functions() { typeset -f "$@"; } - j() { jobs; } - - has_completion() { return 0; } - if [ -z "$BASH_COMPLETION_COMPAT_DIR" ]; then - if [ "$SHELL" = /bin/bash ]; then - if [ -d /usr/share/bash-completion ]; then - . /usr/share/bash-completion/bash_completion - has_completion() { [ -r /usr/share/bash-completion/completions/$1 ]; } - elif [ -f /etc/bash_completion ]; then - . /etc/bash_completion - has_completion() { [ -r /etc/bash_completion.d/$1 ]; } - elif [ -d /etc/bash_completion.d ]; then - for _compf in /etc/bash_completion.d/*; do - . $_compf - done - has_completion() { [ -r /etc/bash_completion.d/$1 ]; } - fi - elif [ "$SHELL" = /usr/local/bin/bash ]; then - if [ -d /usr/local/etc/bash_completion.d ]; then - for _compf in /usr/local/etc/bash_completion.d/*; do - . $_compf - done - has_completion() { [ -r /usr/local/etc/bash_completion.d/$1 ]; } - fi - else - echo "Unknown OS type, cannot source bash_completion" >&2 - fi - fi - - if [ -d "$HOME"/.bash_completion.d ]; then - for _compf in "$HOME"/.bash_completion.d/*; do - . $_compf - done - fi - - for cmd in builtin cgmem_nice command dbus-launch exec \ - killall man nice nohup pidof pidOf KillAll pgrep pkill psg pswg su sudo \ - time whence whereis which xargs; do - ! has_completion $cmd && complete -o default -A command $cmd - done - - for cmd in dig host mtr nslookup nc netcat nmap p ping ping6 socat \ - telnet t tt \ - tcptraceroute tcptraceroute6 tracert tracert6 traceroute traceroute6 \ - whois wd wget wget-download wget-m wget-wrapper ww; do - ! has_completion $cmd && complete -A hostname $cmd - done - - for cmd in distribute ftp lftp r rsync \ - s scp ssh smbclient tcpdump tshark wireshark; do - ! has_completion $cmd && complete -o default -A hostname $cmd - done - - delegate_completion() { - local prog programs - prog=$1 - if has_completion $prog; then - shift - programs="$@" - eval "_${prog}_completion_loader() { - _completion_loader $prog - complete -o nospace -F _$prog $programs - unset _${prog}_completion_loader - return 124 - }" - complete -F _${prog}_completion_loader $programs - fi - } - - delegate_completion make m - delegate_completion ping p - delegate_completion rsync r rsync_cgmn rsync_cgmn_recode - delegate_completion ssh s - delegate_completion wget wget-m wget-wrapper ww - - unset has_completion delegate_completion - - complete -A job bg fg j jobs wait - complete -A variable -A function unset - - if [ -d "$HOME/lib/config" ]; then - complete -W "`cd \"$HOME/lib/config\" && echo *`" include - fi - complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser - - #if type -p pip >/dev/null 2>&1; then - # eval "`pip completion --bash`" - # rm -rf /tmp/pip_build_"$USER" - #fi - - #if which pyenv >/dev/null 2>&1; then - # eval "`pyenv init -`" - # eval "`pyenv virtualenv-init -`" - #fi - - source virtualenvwrapper_lazy.sh 2>/dev/null - - if [ -n "$VIRTUAL_ENV" ] && ! type deactivate >/dev/null 2>&1; then - . "$VIRTUAL_ENV/bin/activate" - fi - - # Clean up python virtual environment on exit - # See https://virtualenvwrapper.readthedocs.io/en/latest/tips.html#clean-up-environments-on-exit - - trap '[ "$VIRTUAL_ENV" ] && deactivate' EXIT - -elif test -n "$KSH_VERSION" -o -n "$FCEDIT"; then - back() { cd - "$@"; } - j() { jobs; } +if test -n "$KSH_VERSION" -o -n "$FCEDIT"; then + back() { cd - "$@"; } + j() { jobs; } fi - # clear screen and history, logout chlo() { clear; cd; >$HISTFILE; unset HISTFILE; history -c; logout || exit; } +if [ -n "$STY" -a "$WINDOW" != 0 ]; then + #unset MAILCHECK everywhere except for the 1st GNU screen window + unset MAILCHECK +fi if test -x /usr/bin/git >/dev/null 2>&1; then - # chdir to a directory - cdgitpath() { - if [ $# -ne 1 ]; then - echo "Usage: cdgitpath path_key" >&2 - return 1 - fi - - path_key="$1" - if [ -z "$path_key" ]; then - echo "Usage: cdgitpath path_key" >&2 - return 1 - fi - - path_url="`git config --get --path $path_key`" - if echo "$path_url" | grep -q '^file:/'; then - path_url="`echo \"$path_url\" | sed 's@^file:/\+@/@'`" - fi - cd "$path_url" - } - - # chdir to a remote's directory (if the remote is on the local FS) - cdremote() { - if [ $# -gt 1 ]; then - echo "Usage: cdremote [remote_name]" >&2 - return 1 - fi - - if [ -z "$1" ]; then - branch="`git rev-parse --abbrev-ref HEAD`" - remote="`git config --get branch.$branch.remote`" - else - remote="$1" - fi - - if [ -n "$remote" ] && git config --get remote.$remote.url | - grep -q '^\(file:/\|/\|\.\./\)'; then # (file:/ or / or ../ at the beginning) - cdgitpath remote.$remote.url - else - - if [ -n "$1" ]; then - echo "Cannot find directory for remote $1" >&2 - echo "Usage: cdremote [remote_name]" >&2 + # chdir to a directory + cdgitpath() { + if [ $# -ne 1 ]; then + echo "Usage: cdgitpath path_key" >&2 return 1 - fi - - if test -n "$BASH_VERSION"; then - _list_remotes '^\(file:/\|/\|\.\./\)' # (file:/ or / or ../ at the beginning) - if [ ${#GIT_REMOTES[*]} -eq 1 ]; then - remote=${GIT_REMOTES[0]} - unset GIT_REMOTES - cdgitpath remote.$remote.url - else - unset GIT_REMOTES - echo "Cannot find directory for any remote" >&2 - echo "Usage: cdremote [remote_name]" >&2 - return 1 - fi - else - echo "Cannot find directory for remote $1" >&2 - echo "Usage: cdremote [remote_name]" >&2 + fi + + path_key="$1" + if [ -z "$path_key" ]; then + echo "Usage: cdgitpath path_key" >&2 return 1 - fi - fi - } - - if test -n "$BASH_VERSION"; then - # completion for aliases in global .gitconfig - - # fixup rbi rbia rbiap rbip - do refs name completion - _git_fixup() { __gitcomp_nl "$(__git_refs)" ; } - _git_rbi() { __gitcomp_nl "$(__git_refs)" ; } - _git_rbia() { __gitcomp_nl "$(__git_refs)" ; } - _git_rbiap() { __gitcomp_nl "$(__git_refs)" ; } - _git_rbip() { __gitcomp_nl "$(__git_refs)" ; } - # - # push-to-all-remotes - do branch name completion - _git_push_to_all_remotes() { __gitcomp_nl "$(__git_heads)" ; } - - _cdgitpath_complete() { - local cur="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=(`compgen -W "$(__git_config_get_set_variables)" -- "$cur"`) - } - - _git_open() { - _cdgitpath_complete - } - - complete -F _cdgitpath_complete cdgitpath git-open - - # list remotes with URLs matching a regexp - _list_remotes() { - if [ $# -ne 1 ]; then - echo "Usage: _list_remotes remote_regexp" >&2 + fi + + path_url="`git config --get --path $path_key`" + if echo "$path_url" | grep -q '^file:/'; then + path_url="`echo \"$path_url\" | sed 's@^file:/\+@/@'`" + fi + cd "$path_url" + } + + # See https://stackoverflow.com/a/77266926/7976758 + + cd_worktree() { + if [ $# -ne 1 ]; then + echo "Usage: cd_worktree " >&2 return 1 - fi - declare -ag GIT_REMOTES=() - local remote - for remote in `git remote`; do - if git config --get remote.$remote.url | grep -q "$1"; then - GIT_REMOTES+=($remote) - fi - done - } - - # completion for cdremote and git-open-remote - list remotes with a pattern - _list_remotes_completion() { - local cur="${COMP_WORDS[COMP_CWORD]}" - _list_remotes "$1" - COMPREPLY=(`compgen -W "${GIT_REMOTES[*]}" -- "$cur"`) - unset GIT_REMOTES - } - - # completion for cdremote - list remotes with directories as URLs - _cdremote_complete() { - _list_remotes_completion '^\(file:/\|/\|\.\./\)' # (file:/ or / or ../ at the beginning) - if [ ${#COMPREPLY[*]} -eq 0 ]; then - _list_remotes_completion . - fi - } - - complete -F _cdremote_complete cdremote - - # completion for git-open-remote - list remotes with http(s) URLs - _git_open_remote() { - _list_remotes_completion '^http\(s\)\?://' - if [ ${#COMPREPLY[*]} -eq 0 ]; then - _list_remotes_completion . - fi - } - - complete -F _git_open_remote git-open-remote - fi + fi + path="$(git worktree list | grep -F "$1" | awk '{print $1}')" + if [ -n "$path" ]; then + cd "$path" + else + echo "Cannot find path for branch '$1'" >&2 + return 1 + fi + } fi - include() { - cfg="$1" - if [ -f "./$cfg" -a -r "./$cfg" ]; then - echo "Reading config file \`$cfg'" 1>&2 - . "./$cfg" - elif [ -f "$HOME/lib/config/$cfg" -a -r "$HOME/lib/config/$cfg" ]; then - echo "Reading config file \`$HOME/lib/config/$cfg'" 1>&2 - . "$HOME/lib/config/$cfg" - else - echo "Cannot find config file \`$cfg'" 1>&2 - fi + cfg="$1" + shift + if [ -f "./$cfg" -a -r "./$cfg" ]; then + echo "Reading config file \`$cfg'" 1>&2 + . "./$cfg" "$@" + elif [ -f "$HOME/lib/config/$cfg" -a -r "$HOME/lib/config/$cfg" ]; then + echo "Reading config file \`$HOME/lib/config/$cfg'" 1>&2 + . "$HOME/lib/config/$cfg" "$@" + else + echo "Cannot find config file \`$cfg'" 1>&2 + fi } +[ "`type -t mc`" = alias ] && unalias mc mc() { - if test -n "$BASH_VERSION"; then - MC_SAVE_OPS1="$OPS1" - OPS1="\u@\h " - fi - - if [ -n "$SLOWTERM" ]; then - MC_SLOW="--slow" - fi - - case "$TERM" in - screen*) # screen, screen.rxvt - MC_XTERM="-x" - ;; - esac - - #TMPDIR="$HOME"/tmp - #export TMPDIR - - MC_FOUND=NO - - for wrapper in \ - /usr/local/share/mc/bin/mc-wrapper.sh \ - /usr/local/libexec/mc/mc-wrapper.sh \ - /usr/share/mc/bin/mc-wrapper.sh; do - if [ -r $wrapper ]; then - . $wrapper $MC_SLOW $MC_XTERM "$@" - rc=$? - MC_FOUND=YES - break - fi - done - - if [ $MC_FOUND = NO ]; then - for mc in /usr/local/bin/mc /usr/bin/mc; do - if [ -x $mc ]; then - MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER" - if [ ! -d MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER" ]; then - MC_TMP_DIR="${TMPDIR-/tmp}" - fi - MC_PWD_FILE="$MC_TMP_DIR/mc.pwd.$$" - mc_type="`mc_type.py $mc`" - if [ "$mc_type" = old ]; then - $mc -P $MC_SLOW $MC_XTERM "$@" > "$MC_PWD_FILE" - elif [ "$mc_type" = new ]; then - $mc -P "$MC_PWD_FILE" $MC_SLOW $MC_XTERM "$@" - else - continue - fi + if [ -n "$SLOWTERM" ]; then + MC_SLOW="--slow" + fi + + case "$TERM" in + screen*) # screen, screen.rxvt + MC_XTERM="-x" + ;; + esac + + #TMPDIR="$HOME"/tmp + #export TMPDIR + + MC_FOUND=NO + + for wrapper in \ + /usr/local/share/mc/bin/mc-wrapper.sh \ + /usr/local/libexec/mc/mc-wrapper.sh \ + /usr/share/mc/bin/mc-wrapper.sh; do + if [ -r $wrapper ]; then + . $wrapper $MC_SLOW $MC_XTERM "$@" rc=$? MC_FOUND=YES - cd "`cat \"$MC_PWD_FILE\"`" && /bin/rm "$MC_PWD_FILE" break - fi - done - fi + fi + done + + if [ $MC_FOUND = NO ]; then + for mc in /usr/local/bin/mc /usr/bin/mc; do + if [ -x $mc ]; then + MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER" + if [ ! -d MC_TMP_DIR="${TMPDIR-/tmp}/mc-$USER" ]; then + MC_TMP_DIR="${TMPDIR-/tmp}" + fi + MC_PWD_FILE="$MC_TMP_DIR/mc.pwd.$$" + mc_type="`mc_type.py $mc`" + if [ "$mc_type" = old ]; then + $mc -P $MC_SLOW $MC_XTERM "$@" > "$MC_PWD_FILE" + elif [ "$mc_type" = new ]; then + $mc -P "$MC_PWD_FILE" $MC_SLOW $MC_XTERM "$@" + else + continue + fi + rc=$? + MC_FOUND=YES + cd "`cat \"$MC_PWD_FILE\"`" && /bin/rm "$MC_PWD_FILE" + break + fi + done + fi - if [ $MC_FOUND = NO ]; then - echo "Cannot find mc-wrapper.sh or mc" >&2 - rc=1 - fi + if [ $MC_FOUND = NO ]; then + echo "Cannot find mc-wrapper.sh or mc" >&2 + rc=1 + fi - [ -n "$MC_SAVE_OPS1" ] && OPS1="$MC_SAVE_OPS1" - unset MC_FOUND MC_PWD_FILE MC_SAVE_OPS1 MC_SLOW MC_TMP_DIR MC_XTERM + unset wrapper MC_FOUND MC_PWD_FILE MC_SLOW MC_TMP_DIR MC_XTERM - return $rc + return $rc } mkcd() { - if [ $# -ne 1 ]; then - echo "Usage: mkcd directory_name" >&2 - elif [ -d "$1" ]; then - cd "$1" - elif [ -e "$1" ]; then - echo "Error: $1 is a file" >&2 - else - mkdir -p "$1" && cd "$1" - fi + if [ $# -ne 1 ]; then + echo "Usage: mkcd directory_name" >&2 + elif [ -d "$1" ]; then + cd "$1" + elif [ -e "$1" ]; then + echo "Error: $1 is a file" >&2 + else + mkdir -p "$1" && cd "$1" + fi } if which tmux >/dev/null 2>&1; then - tmux() { - case "$TERM" in - rxvt) - TERM=rxvt-unicode command tmux "$@" - ;; - - *) - command tmux "$@" - ;; - esac - } + tmux() { + case "$TERM" in + rxvt) + TERM=rxvt-unicode command tmux "$@" + ;; + + *) + command tmux "$@" + ;; + esac + } fi +vim() { + command vim "$@" + rc=$? + cd "`cat \"$HOME/tmp/vim/cwd\"`" && /bin/rm "$HOME/tmp/vim/cwd" && + return $rc +} + + if [ "$SHLVL" -eq 1 ] && which startx >/dev/null 2>&1; then - X() { startx >> .Xserver.log 2>&1; cyr; rm -f .Xauthority; } + X() { startx >> .Xserver.log 2>&1; cyr; /bin/rm -f .Xauthority; } fi x() { exit; } diff --git a/.vim/after/indent/html.vim b/.vim/after/indent/html.vim index 713a16b..54b3866 100644 --- a/.vim/after/indent/html.vim +++ b/.vim/after/indent/html.vim @@ -1,3 +1,6 @@ " Don't re-indent lines on right-angle-bracket setlocal indentkeys-=<>> -let b:undo_ftplugin .= '|setlocal indentkeys<' + +if exists('b:undo_ftplugin') + let b:undo_ftplugin .= '|setlocal indentkeys<' +endif diff --git a/.vim/filetype.vim b/.vim/filetype.vim index 2437ada..e39f2d5 100644 --- a/.vim/filetype.vim +++ b/.vim/filetype.vim @@ -24,7 +24,7 @@ augroup filetypedetect " Python Templates (Quixote) are Python files autocmd BufNewFile,BufReadPost *.ptl setlocal filetype=python " Python Embedded are mason-like python templates - autocmd BufNewFile,BufReadPost *.pyem setlocal filetype=python filetype=mason + autocmd BufNewFile,BufReadPost *.pyem setlocal filetype=python.mason.html " ssh files autocmd BufReadPost known_hosts setlocal filetype=ssh diff --git a/.vim/ftplugin/help.vim b/.vim/ftplugin/help.vim new file mode 100644 index 0000000..93c504b --- /dev/null +++ b/.vim/ftplugin/help.vim @@ -0,0 +1,2 @@ +" https://stackoverflow.com/a/62431902/7976758 +nnoremap diff --git a/.vim/ftplugin/html.vim b/.vim/ftplugin/html.vim index 3950834..87190ba 100644 --- a/.vim/ftplugin/html.vim +++ b/.vim/ftplugin/html.vim @@ -6,7 +6,7 @@ if version >= 702 && has("iconv") && !exists('b:encoding_set') " Try to recognize the file encoding and convert the file let encoding = system("get_html_encoding.py " . shellescape(expand("%"))) if !v:shell_error - if strlen(encoding) != 0 + if !empty(encoding) call SetupEncoding(encoding) endif endif @@ -18,7 +18,7 @@ set shiftwidth=2 softtabstop=2 if expand("%:t") == "bookmarks.html" setlocal textwidth=0 call SetNoWrap() - nmap \h G6k6dd1G0 + nmap \h :%s!!!G6k6dd1G0 else setlocal textwidth=78 endif diff --git a/.vim/ftplugin/javascript.vim b/.vim/ftplugin/javascript.vim new file mode 100644 index 0000000..5887068 --- /dev/null +++ b/.vim/ftplugin/javascript.vim @@ -0,0 +1,5 @@ +if exists("b:did_ftplugin") + finish +endif + +runtime! ftplugin/programming_lang.vim diff --git a/.vim/ftplugin/mail.vim b/.vim/ftplugin/mail.vim index f207edc..89effd9 100644 --- a/.vim/ftplugin/mail.vim +++ b/.vim/ftplugin/mail.vim @@ -12,6 +12,3 @@ if has("iconv") && !exists('b:encoding_set') endif setlocal textwidth=72 - -" SpamCop reports - goto the 9th line and start a browser -nmap z 9G3,b diff --git a/.vim/ftplugin/programming_lang.vim b/.vim/ftplugin/programming_lang.vim new file mode 100644 index 0000000..b05efc9 --- /dev/null +++ b/.vim/ftplugin/programming_lang.vim @@ -0,0 +1,4 @@ +" Settings common to all programming languages + +setlocal formatoptions-=t formatoptions+=croql +setlocal shiftwidth=4 softtabstop=4 diff --git a/.vim/ftplugin/python.vim b/.vim/ftplugin/python.vim index 95333e6..3037539 100644 --- a/.vim/ftplugin/python.vim +++ b/.vim/ftplugin/python.vim @@ -17,9 +17,8 @@ if has("iconv") && !exists('b:encoding_set') endif endif -setlocal formatoptions-=t formatoptions+=croql +runtime! ftplugin/programming_lang.vim setlocal keywordprg=pydoc -setlocal shiftwidth=4 softtabstop=4 compiler python if has("unix") @@ -44,3 +43,6 @@ function! SavePython() endif endif endfunction + +" Avoid double indent. See https://stackoverflow.com/a/62348570/7976758 +let g:pyindent_open_paren=shiftwidth() diff --git a/.vim/ftplugin/sh.vim b/.vim/ftplugin/sh.vim new file mode 100644 index 0000000..5887068 --- /dev/null +++ b/.vim/ftplugin/sh.vim @@ -0,0 +1,5 @@ +if exists("b:did_ftplugin") + finish +endif + +runtime! ftplugin/programming_lang.vim diff --git a/.vim/ftplugin/sshconfig.vim b/.vim/ftplugin/sshconfig.vim new file mode 100644 index 0000000..453ce82 --- /dev/null +++ b/.vim/ftplugin/sshconfig.vim @@ -0,0 +1 @@ +setlocal shiftwidth=4 softtabstop=4 diff --git a/.vim/ftplugin/xml.vim b/.vim/ftplugin/xml.vim index 9069c20..a985607 100644 --- a/.vim/ftplugin/xml.vim +++ b/.vim/ftplugin/xml.vim @@ -6,7 +6,7 @@ if version >= 702 && has("iconv") && !exists('b:encoding_set') " Try to recognize the file encoding and convert the file let encoding = system("get_xml_encoding.py " . shellescape(expand("%"))) if !v:shell_error - if strlen(encoding) == 0 + if empty(encoding) " By default XML files are in UTF-8 let encoding = "UTF-8" endif diff --git a/.vim/plugin/text.vim b/.vim/plugin/text.vim new file mode 100644 index 0000000..77990ed --- /dev/null +++ b/.vim/plugin/text.vim @@ -0,0 +1,12 @@ +function! SearchConflictMarkers() + normal /<<<<<<<\|=======\||||||||\|>>>>>>> +endfunction + +function! StripTrailingSpaces() + %s/ \+$// +endfunction + +function! SqueezeEmptyLines() + " Replace multiple consecutive empty lines with just one + %s/\n\{3,\}/\r\r/ +endfunction diff --git a/.vim/plugin/whichwrap.vim b/.vim/plugin/whichwrap.vim new file mode 100644 index 0000000..66db39a --- /dev/null +++ b/.vim/plugin/whichwrap.vim @@ -0,0 +1 @@ +set whichwrap=b,s,h,l,<,>,[,],~ " Reset it back under GNU screen diff --git a/.vim/python/completion.py b/.vim/python/completion.py index 036aef8..d2681e8 100644 --- a/.vim/python/completion.py +++ b/.vim/python/completion.py @@ -1,71 +1,81 @@ # From http://slobin.pp.ru/vim/_vimrc.html # Adapted to python3 by Oleg Broytman -import sys, rlcompleter, unicodedata, vim -from itertools import * +from itertools import count +import rlcompleter +import sys +import unicodedata + +import vim + + vim_complete = rlcompleter.Completer().complete + def vim_comp_list(): - """Implementation of CompList() function""" - arglead = vim.eval("a:ArgLead") - fence = int(vim.eval("match(a:ArgLead, '\(\w\|\.\)*$')")) - left, right = arglead[:fence], arglead[fence:] - try: - completions = (vim_complete(right, i) for i in count()) - candidates = list(takewhile(bool, completions)) - except NameError: - candidates = [] - suggestions = [left + x for x in candidates] - vim.command("return " + repr(suggestions)) + """Implementation of CompList() function""" + arglead = vim.eval("a:ArgLead") + fence = int(vim.eval("match(a:ArgLead, '\\(\\w\\|\\.\\)*$')")) + left, right = arglead[:fence], arglead[fence:] + try: + completions = (vim_complete(right, i) for i in count()) + candidates = list(takewhile(bool, completions)) + except NameError: + candidates = [] + suggestions = [left + x for x in candidates] + vim.command("return " + repr(suggestions)) + def vim_calc(command): - """Implementation of :Calc command""" - global _ - try: - result = eval(command) - except SyntaxError: - if sys.version_info[0] == 2: - exec(command in globals(), locals()) + """Implementation of :Calc command""" + global _ + try: + result = eval(command) + except SyntaxError: + if sys.version_info[0] == 2: + exec(command in globals(), locals()) + else: + exec(command, globals(), locals()) else: - exec(command, globals(), locals()) - else: - if result != None: - print(result) - _ = result - xx = ''.join(['\\x%02x' % ord(x) for x in str(_)]) - vim.command('let @" = "%s"' % xx) + if result is not None: + print(result) + _ = result + xx = ''.join(['\\x%02x' % ord(x) for x in str(_)]) + vim.command('let @" = "%s"' % xx) + def vim_pydo(command): - """Implementation of :Pydo command""" - codeobj = compile(command, "command", "eval") - line1 = vim.current.range.start - line2 = vim.current.range.end - delta = 0 - for numz in range(line1, line2+1): - line = vim.current.buffer[numz-delta] - if sys.version_info[0] == 2: - uline = unicode(line, vim.eval('&fileencoding')) - else: - uline = line - num = numz + 1 - words = line.split() - result = eval(codeobj, globals(), locals()) - if result is None or result is False: - del vim.current.buffer[numz-delta] - delta += 1 - continue - if isinstance(result, list) or isinstance(result, tuple): - result = " ".join(map(str, result)) - else: - result = str(result) - vim.current.buffer[numz-delta] = result + """Implementation of :Pydo command""" + codeobj = compile(command, "command", "eval") + line1 = vim.current.range.start + line2 = vim.current.range.end + delta = 0 + for numz in range(line1, line2+1): + line = vim.current.buffer[numz-delta] + if sys.version_info[0] == 2: + uline = line.decode(vim.eval('&fileencoding')) + else: + uline = line + num = numz + 1 + words = line.split() + result = eval(codeobj, globals(), locals()) + if result is None or result is False: + del vim.current.buffer[numz-delta] + delta += 1 + continue + if isinstance(result, list) or isinstance(result, tuple): + result = " ".join(map(str, result)) + else: + result = str(result) + vim.current.buffer[numz-delta] = result + def vim_unicode_name(): - try: - char = vim.eval("matchstr(getline('.'), '.', col('.') - 1)") - if sys.version_info[0] == 2: - print(unicodedata.name(char.decode(vim.eval("&encoding")))) - else: - print(unicodedata.name(char)) - except (AttributeError, ValueError) as target: - print("%s: %s" % (target.__class__.__name__, target)) + try: + char = vim.eval("matchstr(getline('.'), '.', col('.') - 1)") + if sys.version_info[0] == 2: + print(unicodedata.name(char.decode(vim.eval("&encoding")))) + else: + print(unicodedata.name(char)) + except (AttributeError, ValueError) as target: + print("%s: %s" % (target.__class__.__name__, target)) diff --git a/.vim/python/virtualenv.py b/.vim/python/virtualenv.py index 3b76fcd..ed46739 100644 --- a/.vim/python/virtualenv.py +++ b/.vim/python/virtualenv.py @@ -1,10 +1,25 @@ -import sys, os +import sys, os # noqa: E401 multiple imports on one line virtualenv_dir = os.environ.get('VIRTUAL_ENV') if virtualenv_dir: - sys.path.insert(0, virtualenv_dir) - activate_this = os.path.join(virtualenv_dir, 'bin', 'activate_this.py') - if sys.version_info[0] == 2: - execfile(activate_this, dict(__file__=activate_this)) - else: - exec(open(activate_this, 'rU').read(), dict(__file__=activate_this)) + 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')) + ): + for activate_this in [ + os.path.join(virtualenv_dir, 'bin', 'activate_this.py'), + os.path.join(virtualenv_dir, 'Scripts', 'activate_this.py') + ]: + if not os.path.exists(activate_this): + continue + if sys.version_info[0] == 2: + execfile(activate_this, # noqa: F821 undefined name 'execfile' + dict(__file__=activate_this)) + else: + exec(open(activate_this, 'r').read(), + dict(__file__=activate_this)) + break diff --git a/.vimrc b/.vimrc index 1138c83..dfa434f 100644 --- a/.vimrc +++ b/.vimrc @@ -47,7 +47,11 @@ set whichwrap=b,s,h,l,<,>,[,],~ " Wrap to the previous/next line on all keys and " 4 displaying text set display=lastline,uhex " Show the last line instead of '@'; show non-printable chars as -set lazyredraw " Do not update screen while executing macros + +" Do not set it here, it breaks initial screen drawing and cursor positioning. +" See SetLazyRedraw at the end of the script. +" set lazyredraw " Do not update screen while executing macros + set list " listchars only works with 'list' " Show tabs, non-breaking/trailing spaces, long lines set listchars=tab:>_,nbsp:_,trail:_,extends:+,precedes:+ @@ -70,6 +74,7 @@ set nohlsearch " Stop the search highlighting set hidden " Don't unload a buffer when no longer shown in a window; allow to switch between buffers/windows when the buffer is modified set laststatus=2 " Always show status line +" set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P " Default statusline set splitbelow " A new window is put below of the current one set splitright " A new window is put right of the current one @@ -80,10 +85,13 @@ set ttyfast " terminal connection is fast set title " Set title to the value of 'titlestring' or to 'filename - VIM' set titleold= " string to restore the title to when exiting Vim -" String to use for the Vim window title; with statusline printf items: +" String to use for the Vim window title; with statusline printf items. +" This is the default: +" display filename, modification flag, full path, and program name in uppercase. +" set titlestring=%t%(\ %M%)%(\ (%{substitute(expand(\"%:p:h\"),\ $HOME,\ \"~\",\ \"\")})%)%(\ %a%)\ -\ %{toupper(v:progname)} " display filename, modification flag, full path, argument list status, " the current user, host and program name (to distinguish vim/view/etc). -set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ [%{$USER}@%{hostname()}]\ %{v:progname} +set titlestring=%t%(\ %M%)%(\ (%{substitute(expand(\"%:p:h\"),\ $HOME,\ \"~\",\ \"\")})%)%(\ %a%)\ -\ %{v:progname}\ [%{$USER}@%{hostname()}] " 9 using the mouse @@ -95,6 +103,10 @@ endif set ruler " Show cursor position below each window set showcmd " Show (partial) command keys in the status line +set visualbell " Use visual bell instead of beeping +if v:version >= 800 + set belloff=error,insertmode " Do not ring the bell for these reasons +endif " Short message for [Modified]; " overwrite message for writing a file with subsequent message; @@ -210,11 +222,13 @@ if has("gui_running") if has("win32") "set guifont=Courier_New:h18:cRUSSIAN set guifont=Lucida_Console:h18:cRUSSIAN - else - set guifont=Monospace\ 16 + elseif has("x11") + set guifont=Monospace\ 18 set toolbar=icons,text " how to show the toolbar endif + set guicursor+=n:block " Block cursor in normal mode + set guicursor+=i:ver10 " Solid vertical bar in insert mode set guicursor+=a:blinkon0 " Stop cursor blinking " Make shift-insert work like in Xterm @@ -258,6 +272,26 @@ else set t_Sb="\e[4%dm" endif + " KP_Up -> Up + map Ox OA + map! Ox OA + " KP_Down -> Down + map Or OB + map! Or OB + " KP_Right -> Right + map Ov OC + map! Ov OC + " KP_Left -> Left + map Ot OD + map! Ot OD + " KP_Home -> Home + map Ow [7~ + map! Ow [7~ + " KP_End -> End + map Oq [8~ + map! Oq [8~ + " KP_Prev (PgDn) and KP_Next (PgUp) work fine, no mapping is required + " 'autoselect' to always put selected text on the clipboard; " 'unnamed' to use the * register like unnamed register '*' " for all yank, delete and put operations; @@ -280,26 +314,7 @@ else endif endif - " Bracketed paste mode - " https://github.com/ConradIrwin/vim-bracketed-paste/blob/master/plugin/bracketed-paste.vim - let &t_ti .= "\[?2004h" - let &t_te = "\e[?2004l" . &t_te - - function! XTermPasteBegin(ret) - set pastetoggle= - set paste - return a:ret - endfunction - - execute "set =\[200~" - execute "set =\[201~" - map XTermPasteBegin("i") - imap XTermPasteBegin("") - vmap XTermPasteBegin("c") - cmap - cmap - - "https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode + " https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode " https://ttssh2.osdn.jp/manual/en/usage/tips/vim.html function! WrapForScreenTmux(s) if (&term =~ "screen") @@ -380,13 +395,13 @@ autocmd BufReadPost * call RestorePosition() function! SetupEncoding(encoding) - if !has("iconv") || exists('b:encoding_set') || strlen(a:encoding) == 0 + if !has("iconv") || exists('b:encoding_set') || empty(a:encoding) return endif call RestorePosition() let b:encoding_set = 1 - if len(expand('%')) + if !empty(expand('%')) execute "edit ++enc=" . a:encoding endif endfunction @@ -452,7 +467,7 @@ function! ExtractURL() let line = getline('.') let parts = split(line, s:URL_re . '\zs') - if len(parts) == 0 + if empty(parts) throw 'ExtractURLCannotFindURL' " No URL found endif @@ -508,10 +523,12 @@ endfunction nmap \b :call ExtractOpenURL('') nmap \w :call ExtractOpenURL('-n') nmap \t :call ExtractOpenURL('-t') +nmap \p :call ExtractOpenURL('-p') " Send visual block to a browser vmap \b ""y:call OpenURL('"', '') vmap \w ""y:call OpenURL('"', '-n') vmap \t ""y:call OpenURL('"', '-t') +vmap \p ""y:call OpenURL('"', '-p') " Encode and send visual block to a browser vmap \B ""y:call EncodeOpenURL('"', '') vmap \W ""y:call EncodeOpenURL('"', '-n') @@ -575,13 +592,13 @@ function! W() execute 'set fileencoding=' . e w break - catch /E513: write error, conversion failed/ + catch /E513: [Ww]rite error, conversion failed/ continue endtry endfor if &modified - throw '"' . expand('%') . '" E513: write error, conversion failed; tried ' . join(encodings, ',') + throw '"' . expand('%') . '" E513: Write error, conversion failed; tried ' . join(encodings, ',') elseif has("spell") call SetupSpell() endif @@ -707,8 +724,6 @@ command! Text call Text() function! AutoEncoding() if &modified && &fileencoding != "" call SetupEncoding(&fileencoding) - else - redraw endif autocmd! auto-encoding augroup! auto-encoding @@ -775,7 +790,7 @@ if has("spell") autocmd BufReadPost * call SetupSpell() function! SaveSpell() - if expand('%') == expand('~/.vim/spell/en.ascii.add') + if expand('%:p') == expand('~/.vim/spell/en.ascii.add') mkspell! -ascii % else mkspell! % @@ -835,5 +850,15 @@ command! UName Uname endif " ---------- +if v:version >= 800 + function! SetLazyRedraw(timer_id) + call timer_stop(a:timer_id) " One-time event + set lazyredraw + endfunction + call timer_start(500, 'SetLazyRedraw') +endif + +autocmd VimLeave * call writefile([getcwd()], expand('~/tmp/vim/cwd')) + " This has to go to the very end of ~/.vimrc to allow reading the .vimrc set secure " safer working with script files in the current directory diff --git a/.xinitrc b/.xinitrc index 4a1b23f..97c72d0 100644 --- a/.xinitrc +++ b/.xinitrc @@ -48,7 +48,7 @@ setxkbmap -layout 'us,ru' -variant ',common' -option 'grp:toggle,grp:shifts_togg #setxkbmap -option terminate:ctrl_alt_bksp # adjust key bindings (if any) -#[ -f "$HOME"/lib/X11/.Xmodmap ] && xmodmap "$HOME"/lib/X11/.Xmodmap +[ -f "$HOME"/lib/X11/.Xmodmap ] && xmodmap "$HOME"/lib/X11/.Xmodmap # X settings: shorter beep #xset b 50 400 50 @@ -67,7 +67,7 @@ xscreensaver & xbindkeys xxkb & -synclient AccelFactor=0.1 MaxDoubleTapTime=80 MaxSpeed=1 RightEdge=5000 \ +synclient AccelFactor=0.1 MaxDoubleTapTime=80 MaxSpeed=1 RightEdge=3350 \ TapButton1=1 TapButton2=2 TapButton3=3 HorizEdgeScroll=1 VertEdgeScroll=1 # Turn mouse off on keyboard activity; turn it back on after 1 second @@ -76,10 +76,16 @@ synclient AccelFactor=0.1 MaxDoubleTapTime=80 MaxSpeed=1 RightEdge=5000 \ # start a small console shell #xterm -C -geometry 80x8-0+0 -n Console -T Consle -ls +ut -fn 6x10 & -#WIDTH=1024: 85x85+400+1 -#WIDTH=1600: 100x100+600+1 -#WIDTH=1920: 150x150+880+1 -xclock -geometry 100x100+600+1 -bg white -update 1 & +screen_width=`xrandr --current | head -1 | awk '{print $8}'` +if [ $screen_width = 1024 ]; then + xclcok_geom=85x85+400+1 +elif [ $screen_width = 1600 ]; then + xclcok_geom=100x100+600+1 +elif [ $screen_width = 1920 ]; then + xclcok_geom=150x150+880+1 +fi +test -n "$xclcok_geom" && xclock -geometry $xclcok_geom -bg white -update 1 & +unset screen_width xclcok_geom # multi-biff #xbuffy -fn '-*-helvetica-bold-r-*-*-*-100-*-*-*-*-koi8-r' -geometry +0+125 -boxfile mail/misc/.xbuffyrc & @@ -92,6 +98,6 @@ fi dbus-launch --exit-with-session gpg-agent --daemon "$WINDOW_MANAGER" # Stop pulseaudio, xscreensaver and xsetbg.py -pulseaudio -k +pulseaudio --kill xscreensaver-command -exit & "$HOME"/current/projects/xsetbg/xsetbg-http-stop & diff --git a/admin/prog/bash_prompt b/admin/prog/bash_prompt new file mode 100644 index 0000000..903a58b --- /dev/null +++ b/admin/prog/bash_prompt @@ -0,0 +1,163 @@ +cgmem_which_prompt() { + local _cgmem_which + _cgmem_which="`cgmem_which 2>/dev/null`" + if [ -n "$_cgmem_which" ]; then + _cgmem_which=" $_cgmem_which" + fi + echo "$_cgmem_which" +} + +last_cmd_status() { + local _last_status=$? + if [ $_last_status -eq 0 ]; then + echo '+' + elif [ $_last_status -ge 1 ]; then + echo '-' + else + echo '?' + fi +} + +# Cut directories to 20% of the terminal width; add space for 3 dots +_DIR_LENGTH=`awk "END { print int(0.2 * ${COLUMNS:-80}) }" /dev/null +} + +prompt_git() { + local s="" + local branchName="" + + # check if the current directory is in a git repository + if git rev-parse --is-inside-work-tree &>/dev/null; then + + # check if the current directory is in .git before running git checks + if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == "false" ]; then + + # ensure index is up to date + #git update-index --really-refresh -q &>/dev/null + + # check for unstaged changes + if [ -n "$(_recurse_submodules git ls-files --modified :/)" ]; then + s="$s*"; + fi + + # check for uncommitted changes in the index + if [ -n "$(_recurse_submodules git diff --ignore-submodules --cached)" ]; then + s="$s+"; + fi + + # check for stashed files + if [ -n "$(_recurse_submodules git rev-parse --verify refs/stash)" ]; then + s="$s$"; + fi + + # check for untracked files + if [ -n "$(_recurse_submodules git ls-files --others --exclude-standard :/)" ]; then + s="$s%"; + fi + + fi + + # get the short symbolic ref + # if HEAD isn't a symbolic ref, get the short SHA + # otherwise, just give up + branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ + git rev-parse --short HEAD 2> /dev/null || \ + printf "(unknown)")" + + up=`git rev-parse --abbrev-ref @{u} 2>/dev/null` + if [ -n "$up" -a "$up" != "@{u}" ]; then + local left right + set -- `git rev-list --count --left-right @{u}...HEAD` + left=$1 + right=$2 + if [ "$left" -gt 0 ]; then + s="$s-$left" + fi + if [ "$right" -gt 0 ]; then + s="$s+$right" + fi + fi + + [ -n "$s" ] && s=" $s" + printf " (%s)" "$branchName$s" + fi +} + +#if test -x /usr/bin/git >/dev/null 2>&1; then +# if [ "`type -t __git_ps1`" != function ]; then +# git_sh_prompt=`git --exec-path`/git-sh-prompt +# test -r $git_sh_prompt && . $git_sh_prompt || : +# fi +# if [ "`type -t __git_ps1`" = function ]; then +# GIT_PS1_SHOWDIRTYSTATE=true +# GIT_PS1_SHOWSTASHSTATE=true +# GIT_PS1_SHOWUNTRACKEDFILES=true +# GIT_PS1_SHOWUPSTREAM=verbose +# fi +#fi + +set_prompt() { + PS1='' + local _SHORT_PROMPT='[\A`cgmem_which_prompt`] \u@${HOSTNAME::5}:`short_curdir`' + # display the user, host and current working directory + # in the terminal title + case "$TERM" in + *rxvt*|screen*|*term*|vt100) + PS1+="\033]0;${debian_chroot:+($debian_chroot)}\u@\h:\w\007" # Set xterm title/icon + case "$TERM" in + screen*) + PS1+="\033P${PS1}\033\\\\" # Set xterm title/icon under screen/tmux + if [ -z "$MC_SID" ]; then + PS1+="\033k${_SHORT_PROMPT}\033\\\\" # Set screen/tmux caption + fi + ;; + esac + ;; + esac + + # This is for .screenrc: shelltitle "\$ |$SHELL" + #PS1+='\033k\033\\' + + PS1="\[$PS1\]" + PS1+='${debian_chroot:+($debian_chroot)}' + PS1+=${_SHORT_PROMPT} + if test -x /usr/bin/git >/dev/null 2>&1; then + #if [ "`type -t __git_ps1`" = function ]; then + # PS1+='$(__git_ps1)' + #else + PS1+='$(prompt_git)' + #fi + fi + PS1+=' $SHLVL\$ ' +} diff --git a/bin/GET.py b/bin/GET.py index f7fddbd..2f00d89 100755 --- a/bin/GET.py +++ b/bin/GET.py @@ -1,71 +1,68 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 +from urllib.parse import urlsplit, parse_qsl, quote, quote_plus, urlencode +from urllib.request import urlretrieve +import os +import socket import sys -url = sys.argv[1] - -import urllib -urllib._urlopener = urllib.FancyURLopener() - -from cgi import parse_qsl -from m_lib.defenc import default_encoding +import urllib.request -protocol, request = urllib.splittype(url) -user, password, port = None, None, None -host, path = urllib.splithost(request) -if host: - user, host = urllib.splituser(host) - if user: - user, password = urllib.splitpasswd(user) - host, port = urllib.splitport(host) - if port: port = int(port) -path, tag = urllib.splittag(path) -path, query = urllib.splitquery(path) -path = urllib.unquote(path) -if tag: tag = urllib.unquote_plus(tag) +url = sys.argv[1] -if query: - qlist = [] - for name, value in parse_qsl(query): - qlist.append((name, value)) +split_results = urlsplit(url) +protocol, netloc, path, query, tag = split_results +user = split_results.username +password = split_results.password +host = split_results.hostname +port = split_results.port +qlist = parse_qsl(query) url = protocol + "://" if user: - url += urllib.quote(user) - if password: - url += ':' + urllib.quote(password) - url += '@' + url += quote(user) + if password: + url += ':' + quote(password) + url += '@' if host: - url += host.decode(default_encoding).encode('idna') - if port: - url += ':%d' % port + host = host.encode('idna').decode('ascii') + url += host + if port: + url += ':%d' % port if path: - if protocol == "file": - url += urllib.quote(path) - else: - url += urllib.quote(path) + if protocol == "file": + url += quote(path) + else: + url += quote(path) if query: - url += '?' + urllib.urlencode(qlist) + url += '?' + urlencode(qlist) if tag: - url += '#' + urllib.quote_plus(tag) + url += '#' + quote_plus(tag) # I remember seeing some sites that return broken HTML or even HTTP response # without "compatible" user agent; I don't know if such sites are still around, # but this header doesn't cause any harm so I'd better continue to use it. # UPDATE: I saw a number of sites that forbid "Mozilla compatible" -server_version = "Python-urllib/%s" % urllib.__version__ -urllib._urlopener.addheaders[0] = ('User-agent', server_version) -urllib._urlopener.addheaders.append(('Accept-Charset', "koi8-r;q=1.0")) +urllib_version = urllib.request.__version__ +server_version = "Python-urllib/%s" % urllib_version -import os -dest_file = os.path.basename(url) +class MyURLopener(urllib.request.URLopener): + def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): + return urllib.request.URLopener.open(self, fullurl, data) + + +_urlopener = urllib.request._opener = MyURLopener() +_urlopener.addheaders[0] = ('User-agent', server_version) +_urlopener.addheaders.append(('Accept-Charset', "koi8-r;q=1.0")) + +dest_file = os.path.basename(url) if not dest_file: - dest_file = "_index.html" + dest_file = "_index.html" -filename, headers = urllib.urlretrieve(url, dest_file) +filename, headers = urlretrieve(url, filename=dest_file) -if headers.has_key("last-modified"): - from m_lib.net.www.util import parse_time - last_modified = parse_time(headers["last-modified"]) - if last_modified: - os.utime(dest_file, (last_modified, last_modified)) +if "last-modified" in headers: + from m_lib.net.www.util import parse_time + last_modified = parse_time(headers["last-modified"]) + if last_modified: + os.utime(dest_file, (last_modified, last_modified)) diff --git a/bin/HEAD.py b/bin/HEAD.py index c7b3764..6c0e5f7 100755 --- a/bin/HEAD.py +++ b/bin/HEAD.py @@ -1,61 +1,57 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 +from http.client import HTTPConnection, HTTPSConnection +from urllib.parse import urlsplit, parse_qsl, urlencode, quote, quote_plus import sys -url = sys.argv[1] - -import socket -socket.setdefaulttimeout(30) +import urllib.request -from cgi import parse_qsl -import urllib -from m_lib.defenc import default_encoding +url = sys.argv[1] -protocol, request = urllib.splittype(url) -user, password, port = None, None, None -host, path = urllib.splithost(request) +split_results = urlsplit(url) +protocol, netloc, path, query, tag = split_results +user = split_results.username +password = split_results.password +host = split_results.hostname +port = split_results.port +qlist = parse_qsl(query) + +url = protocol + "://" +if user: + url += quote(user) + if password: + url += ':' + quote(password) + url += '@' if host: - user, host = urllib.splituser(host) - if user: - user, password = urllib.splitpasswd(user) - host, port = urllib.splitport(host) - if port: port = int(port) -path, tag = urllib.splittag(path) -path, query = urllib.splitquery(path) -path = urllib.unquote(path) -if tag: tag = urllib.unquote_plus(tag) - -if query: - qlist = [] - for name, value in parse_qsl(query): - qlist.append((name, value)) - -url = '' -host = host.decode(default_encoding).encode('idna') + host = host.encode('idna').decode('ascii') + url += host + if port: + url += ':%d' % port if path: - url += urllib.quote(path) + if protocol == "file": + url += quote(path) + else: + url += quote(path) if query: - url += '?' + urllib.urlencode(qlist) + url += '?' + urlencode(qlist) if tag: - url += '#' + urllib.quote_plus(tag) + url += '#' + quote_plus(tag) -import httplib -server = httplib.HTTP(host, port) +if protocol == "https": + server = HTTPSConnection(host, port) +else: + server = HTTPConnection(host, port) server.set_debuglevel(1) - server.putrequest("HEAD", path) -if port: - server.putheader("Host", '%s:%d' % (host, port)) -else: - server.putheader("Host", host) # I remember seeing some sites that return broken HTML or even HTTP response # without "compatible" user agent; I don't know if such sites are still around, # but this header doesn't cause any harm so I'd better continue to use it. # UPDATE: I saw a number of sites that forbid "Mozilla compatible" -client_version = "Python-urllib/%s" % urllib.__version__ +urllib_version = urllib.request.__version__ +client_version = "Python-urllib/%s" % urllib_version server.putheader('User-agent', client_version) server.putheader('Accept-Charset', "koi8-r;q=1.0") server.endheaders() -server.getreply() +server.getresponse() diff --git a/bin/KillAll b/bin/KillAll index 92dbf74..63ae4dc 100755 --- a/bin/KillAll +++ b/bin/KillAll @@ -3,8 +3,9 @@ # A kind of pkill/killall if [ -z "$1" -o -n "$3" ]; then echo "Usage: KillAll [-signal] proc_regexp" >&2 - return 1 + exit 1 fi + if [ -z "$2" ]; then kill `pidOf "$1"` else diff --git a/bin/PS b/bin/PS index 67574b5..7fbd8b1 100755 --- a/bin/PS +++ b/bin/PS @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys, os @@ -13,5 +13,5 @@ if pager == 'less': opt = 'S' if opt not in less: less = opt + less - os.environ["LESS"] = less + os.environ["LESS"] = less os.system("ps %s | %s" % (args, pager)) diff --git a/bin/abspath.py b/bin/abspath.py index fe57b54..cbda1c8 100755 --- a/bin/abspath.py +++ b/bin/abspath.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys, os -print os.path.abspath(sys.argv[1]) +print(os.path.abspath(sys.argv[1])) diff --git a/bin/browser-stack.py b/bin/browser-stack.py index 0deb390..7120479 100755 --- a/bin/browser-stack.py +++ b/bin/browser-stack.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 from __future__ import print_function import sys, os diff --git a/bin/browser_stack.py b/bin/browser_stack.py index 94e6c60..7018dc6 100644 --- a/bin/browser_stack.py +++ b/bin/browser_stack.py @@ -4,7 +4,7 @@ browser_stack = os.path.expanduser('~/.cache/browser-stack') def get_stack(): try: - with open(browser_stack, 'rU') as stack_file: + with open(browser_stack, 'r') as stack_file: return stack_file.readlines() except IOError: # No such file return [] @@ -19,4 +19,5 @@ def save_stack(stack): def set_current_browser(): stack = get_stack() if stack: - os.environ['BROWSER'] = stack[0].strip() + os.environ['BROWSER'] = browser = stack[0].strip() + return browser diff --git a/bin/cgmem_nice b/bin/cgmem_nice index a509f6b..aa8eecc 100755 --- a/bin/cgmem_nice +++ b/bin/cgmem_nice @@ -1,12 +1,12 @@ #! /bin/sh usage() { - echo "Usage: $0 {100|200|300|500|1000|2000|4000} [command [args]]" + echo "Usage: $0 {100|200|300|400|500|1000|2000|4000|5000} [command [args]]" exit 1 } case "$1" in - 100|200|300|500|1000|2000|4000) + 100|200|300|400|500|1000|2000|4000|5000) ;; *) usage @@ -16,7 +16,7 @@ esac size="$1" # in megabytes shift -CGROUPS=/sys/fs/cgroup +CGROUPS=/sys/fs/cgroup/memory echo $$ > "$CGROUPS"/${size}M/tasks || exit 1 ulimit -d ${size}000 diff --git a/bin/cgmem_which b/bin/cgmem_which new file mode 100755 index 0000000..ed03705 --- /dev/null +++ b/bin/cgmem_which @@ -0,0 +1,2 @@ +#! /bin/sh +grep -Flw $$ /sys/fs/cgroup/memory/*M/tasks | cut -d/ -f6 diff --git a/bin/cgmn b/bin/cgmn new file mode 120000 index 0000000..48c5ae3 --- /dev/null +++ b/bin/cgmn @@ -0,0 +1 @@ +cgmem_nice \ No newline at end of file diff --git a/bin/cleanup-filenames.sh b/bin/cleanup-filenames.sh index c977312..a517e96 100755 --- a/bin/cleanup-filenames.sh +++ b/bin/cleanup-filenames.sh @@ -7,7 +7,7 @@ fi for fname in "$@"; do - newname=$(echo "$fname" | sed -e " + newname=$(echo "$fname" | sed -e " s/[‘“’”‘“’”″′«»\`\"]/'/g s/ *: */ - /g s/[–—]/-/g @@ -17,10 +17,11 @@ s/\?//g s/№/N/g ") - if [ "$fname" \!= "$newname" ]; then - echo "$fname" - echo "$newname" - mv -- "$fname" "$newname" - echo - fi + newname="$(unicode_norm_nfd.py "$newname")" + if [ "$fname" \!= "$newname" ]; then + echo "$fname" + echo "$newname" + mv -- "$fname" "$newname" + echo + fi done diff --git a/bin/cleanup-recode.sh b/bin/cleanup-recode.sh index 427cd6d..3f8213d 100755 --- a/bin/cleanup-recode.sh +++ b/bin/cleanup-recode.sh @@ -16,7 +16,7 @@ while getopts f:t: opt; do done shift `expr $OPTIND - 1` -for dir in "$@"; do +for dir in "${@:-.}"; do cleanup-filenames-recursive.sh "$dir" && recode-filenames-recursive.py "$from_enc" "$to_enc" "$dir" || exit 1 done diff --git a/bin/cmp.py b/bin/cmp.py index 37cc0ff..800e119 100755 --- a/bin/cmp.py +++ b/bin/cmp.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """cmp.py: compare two files. Replace cmp because standard cmp cannot compare large files. """ @@ -6,11 +6,11 @@ large files. import sys, os if sys.argv[1] in ("-h", "--help"): - print "Broytman cmp.py 1.0, Copyright (C) 2003 PhiloSoft Design" - print "Usage: cmp.py [-h|--help|-V|--version] [-i] file1 file2" + print("Broytman cmp.py 1.0, Copyright (C) 2003-2023 PhiloSoft Design") + print("Usage: cmp.py [-h|--help|-V|--version] [-i] file1 file2") sys.exit() elif sys.argv[1] in ("-V", "--version"): - print "Broytman cmp.py 1.0, Copyright (C) 2003 PhiloSoft Design" + print("Broytman cmp.py 1.0, Copyright (C) 2003-2023 PhiloSoft Design") sys.exit() elif sys.argv[1] == "-i": show_pbar = False @@ -31,7 +31,7 @@ if show_pbar: try: size = os.path.getsize(fname1) except: - print filename, ": no such file" + print(filename, ": no such file") sys.exit(1) if show_pbar: @@ -62,7 +62,7 @@ while True: pbar.display(file1.tell()) if block1 and block2: - if len(block1) <> len(block2): + if len(block1) != len(block2): report() break elif block1: @@ -74,7 +74,7 @@ while True: else: break - if block1 <> block2: + if block1 != block2: report() break diff --git a/bin/compyle b/bin/compyle index 4050467..da48caf 100755 --- a/bin/compyle +++ b/bin/compyle @@ -5,5 +5,5 @@ if [ -z "$1" ]; then exit 1 fi - python$PY_VER -m compileall "$@" && -exec python$PY_VER -O -m compileall "$@" + python$PY_VER -m compileall -x '\.tox/' -x '\.venv/' -x 'venv/' "$@" +exec python$PY_VER -O -m compileall -x '\.tox/' -x '\.venv/' -x 'venv/' "$@" diff --git a/bin/compyle4vim.py b/bin/compyle4vim.py index 88a5705..08f9324 100755 --- a/bin/compyle4vim.py +++ b/bin/compyle4vim.py @@ -1,5 +1,4 @@ -#! /usr/bin/env python - +#! /usr/bin/env python3 import sys, os diff --git a/bin/compyleall b/bin/compyleall index f78f33d..70e95c8 100755 --- a/bin/compyleall +++ b/bin/compyleall @@ -1,3 +1,4 @@ #! /bin/sh - python$PY_VER -m compileall . && + + python$PY_VER -m compileall . exec python$PY_VER -O -m compileall . diff --git a/bin/cp_recode_fname b/bin/cp_recode_fname new file mode 100755 index 0000000..d6dd74b --- /dev/null +++ b/bin/cp_recode_fname @@ -0,0 +1,40 @@ +#! /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" ;; + mv_*) cmd=mv ;; + *) + 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" diff --git a/bin/decode-URLs.py b/bin/decode-URLs.py index 70400ab..ef04664 100755 --- a/bin/decode-URLs.py +++ b/bin/decode-URLs.py @@ -1,12 +1,16 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 -import sys, urllib +try: + from urllib.parse import unquote +except ImportError: + from urllib import unquote +import sys while True: url = sys.stdin.readline() if not url: break - unqoted = urllib.unquote(url.strip()) + unqoted = unquote(url.strip()) if unqoted.startswith('file://'): unqoted = unqoted[len('file://'):] - print unqoted + print(unqoted) diff --git a/bin/get_html_encoding.py b/bin/get_html_encoding.py index 8fd9656..381be9c 100755 --- a/bin/get_html_encoding.py +++ b/bin/get_html_encoding.py @@ -1,18 +1,13 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 - -from HTMLParser import HTMLParseError from m_lib.net.www.html import HTMLParser as _HTMLParser - class HTMLHeadDone(Exception): pass - class HTMLParser(_HTMLParser): def end_head(self): raise HTMLHeadDone() - def do_meta(self, attrs): http_equiv = "" content = "" @@ -41,14 +36,14 @@ def parse_html(filename): for line in infile: try: parser.feed(line) - except (HTMLParseError, HTMLHeadDone): + except HTMLHeadDone: break infile.close() try: parser.close() - except (HTMLParseError, HTMLHeadDone): + except HTMLHeadDone: pass if hasattr(parser, "charset"): @@ -62,12 +57,12 @@ if __name__ == '__main__': import sys parser = parse_html(sys.argv[1]) if hasattr(parser, "charset"): - print parser.charset + print(parser.charset) else: import chardet charset = chardet.detect(open(sys.argv[1]).read())["encoding"] if charset in ("ISO-8859-2", "MacCyrillic"): charset = "cp1251" - print charset + print(charset) except: pass diff --git a/bin/get_xml_encoding.py b/bin/get_xml_encoding.py index 5007971..cdd9b6b 100755 --- a/bin/get_xml_encoding.py +++ b/bin/get_xml_encoding.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 charset = None def xml_decl_handler(version, encoding, standalone): @@ -12,7 +12,7 @@ if __name__ == '__main__': import xml.parsers.expat parser = xml.parsers.expat.ParserCreate() parser.XmlDeclHandler = xml_decl_handler - parser.ParseFile(open(sys.argv[1], 'r')) + parser.ParseFile(open(sys.argv[1], 'rb')) except: pass - if charset: print charset + if charset: print(charset) diff --git a/bin/git-open b/bin/git-open index b25e8d9..4cf5946 100755 --- a/bin/git-open +++ b/bin/git-open @@ -1,7 +1,12 @@ #! /bin/sh +if [ "x$1" = x-p ]; then + private="-p" + shift +fi + if [ $# -ne 1 ]; then - echo "Usage: git open url_key" >&2 + echo "Usage: git open [-p] url_key" >&2 exit 1 fi @@ -13,7 +18,9 @@ fi browser_section="`git config --get web.browser`" browser_cmd="`git config --get browser.\"$browser_section\".cmd`" -if [ -z "$browser_cmd" ]; then +if [ x"$private" = x-p ]; then + browser_cmd="webbrowser -p" +elif [ -z "$browser_cmd" ]; then browser_cmd="webbrowser -n" fi diff --git a/bin/git-open-remote b/bin/git-open-remote index 45c3a7e..9aa6a84 100755 --- a/bin/git-open-remote +++ b/bin/git-open-remote @@ -1,5 +1,10 @@ #! /bin/sh +if [ "x$1" = x-p ]; then + private="-p" + shift +fi + if [ -z "$1" ]; then branch="`git rev-parse --abbrev-ref HEAD`" remote="`git config --get branch.$branch.remote`" @@ -16,4 +21,4 @@ if [ -z "$remote" ]; then exit 1 fi -exec git-open remote.$remote.url +exec git-open $private remote.$remote.url diff --git a/bin/iconv.py b/bin/iconv.py index 41631fe..9cb164f 100755 --- a/bin/iconv.py +++ b/bin/iconv.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 "Recode to default charset" import sys @@ -10,19 +10,23 @@ to_charset = default_encoding 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 + 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: - infile = open(file) - try: - for line in infile: - sys.stdout.write(unicode(line, from_charset, "replace").encode(to_charset, "replace")) - except: - infile.close() + for file in arguments: + with open(file, 'rb') as infile: + for line in infile: + output.write( + line.decode(from_charset, "replace"). + encode(to_charset, "replace")) else: - for line in sys.stdin: - sys.stdout.write(unicode(line, from_charset, "replace").encode(to_charset, "replace")) + input = getattr(sys.stdin, 'buffer', sys.stdin) + for line in input: + output.write( + line.decode(from_charset, "replace").encode(to_charset, "replace")) diff --git a/bin/iconvx.py b/bin/iconvx.py index 9352e73..b4c990e 100755 --- a/bin/iconvx.py +++ b/bin/iconvx.py @@ -1,37 +1,38 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 "iconv wrapper" -import sys from getopt import getopt +import os, shutil, sys, 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 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" + 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" + raise ValueError("you must use -t param to name destination charset") -import tempfile, os, shutil tempfname = "_iconvx" + tempfile.gettempprefix() + "tmp" if arguments: - try: - for file in arguments: - os.system("iconv.py -f '%s' -t '%s' '%s' > '%s'" % (from_charset, to_charset, file, tempfname)) + try: + for file in arguments: + os.system( + "iconv.py -f '%s' -t '%s' '%s' > '%s'" % ( + from_charset, to_charset, file, tempfname)) shutil.copy2(tempfname, file) - finally: - os.unlink(tempfname) + finally: + os.unlink(tempfname) -else: # filter stdin => stdout - os.system("iconv.py -f '%s' -t '%s'" % (from_charset, to_charset)) +else: # filter stdin => stdout + os.system("iconv.py -f '%s' -t '%s'" % (from_charset, to_charset)) diff --git a/bin/iconvxml.py b/bin/iconvxml.py deleted file mode 100755 index 86eb66d..0000000 --- a/bin/iconvxml.py +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/bin/env python -"Recode using XML char references" - -import sys -from getopt import getopt -from m_lib.defenc import default_encoding - -from_charset = "utf-8" -to_charset = default_encoding - -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 - -if arguments: - for file in arguments: - infile = open(file) - try: - for line in infile: - sys.stdout.write(unicode(line, from_charset, "replace").encode(to_charset, "xmlcharrefreplace")) - except: - infile.close() -else: - for line in sys.stdin: - sys.stdout.write(unicode(line, from_charset, "replace").encode(to_charset, "xmlcharrefreplace")) diff --git a/bin/idna.py b/bin/idna.py index a0dabc6..44843ac 100755 --- a/bin/idna.py +++ b/bin/idna.py @@ -1,6 +1,8 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys +from m_lib.defenc import default_encoding + l = len(sys.argv) if (l == 2) and (sys.argv[1] != '-r'): @@ -10,12 +12,13 @@ elif (l == 3) and (sys.argv[1] == '-r'): reverse = True address = sys.argv[2] else: - print >>sys.stderr, 'Usage: %s [-r] name.domain' % sys.argv[0] - sys.exit(1) - -from m_lib.defenc import default_encoding + sys.exit('Usage: %s [-r] name.domain' % sys.argv[0]) if reverse: - print address.decode("idna").encode(default_encoding) + if not isinstance(address, bytes): + address = address.encode('ascii') + print(address.decode("idna")) else: - print unicode(address, default_encoding).encode("idna") + if isinstance(address, bytes): + address = address.decode(default_encoding) + print(address.encode("idna").decode('ascii')) diff --git a/bin/koi2lat b/bin/koi2lat index e5cd63b..4687100 100755 --- a/bin/koi2lat +++ b/bin/koi2lat @@ -1,10 +1,8 @@ -#! /usr/bin/env python - +#! /usr/bin/env python3 import sys from m_lib.rus import rus2lat - for line in sys.stdin: - if line[-1] == '\n': line = line[:-1] - print rus2lat.rus2lat(line) + if line[-1] == '\n': line = line[:-1] + print(rus2lat.rus2lat(line)) diff --git a/bin/l b/bin/l index 73a0458..193d6b4 100755 --- a/bin/l +++ b/bin/l @@ -1,14 +1,14 @@ #! /bin/sh case "$TERM" in - *rxvt*|screen*|*term*|vt100) - TERM=xterm - export TERM + *rxvt*|screen*|*term*|vt100) - xtitle "links@${HOSTNAME}" - exec links2 "$@" - ;; + xtitle "links@${HOSTNAME}" + tput smcup + TERM=xterm links2 "$@" + exec tput rmcup + ;; - *)echo "Wrong TERM" >&2 - ;; + *)echo "Wrong TERM" >&2 + ;; esac diff --git a/bin/lat2koi b/bin/lat2koi index c4ed131..9c43755 100755 --- a/bin/lat2koi +++ b/bin/lat2koi @@ -1,10 +1,8 @@ -#! /usr/bin/env python - +#! /usr/bin/env python3 import sys from m_lib.rus import lat2rus - for line in sys.stdin: - if line[-1] == '\n': line = line[:-1] - print lat2rus.lat2rus(line) + if line[-1] == '\n': line = line[:-1] + print(lat2rus.lat2rus(line)) diff --git a/bin/latin1_to_ascii.py b/bin/latin1_to_ascii.py deleted file mode 100755 index 974edd9..0000000 --- a/bin/latin1_to_ascii.py +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/env python - -# See http://code.activestate.com/recipes/251871/ - -import sys, os - -xlate = { - u'\N{ACUTE ACCENT}': "'", - u'\N{BROKEN BAR}': '|', - u'\N{CEDILLA}': '{cedilla}', - u'\N{CENT SIGN}': '{cent}', - u'\N{COPYRIGHT SIGN}': '{C}', - u'\N{CURRENCY SIGN}': '{currency}', - u'\N{DEGREE SIGN}': '{degrees}', - u'\N{DIAERESIS}': '{umlaut}', - u'\N{DIVISION SIGN}': '/', - u'\N{FEMININE ORDINAL INDICATOR}': '{^a}', - u'\N{INVERTED EXCLAMATION MARK}': '!', - u'\N{INVERTED QUESTION MARK}': '?', - u'\N{LATIN CAPITAL LETTER A WITH ACUTE}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH CIRCUMFLEX}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH DIAERESIS}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH GRAVE}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH RING ABOVE}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH TILDE}': 'A', - u'\N{LATIN CAPITAL LETTER AE}': 'Ae', - u'\N{LATIN CAPITAL LETTER C WITH CEDILLA}': 'C', - u'\N{LATIN CAPITAL LETTER E WITH ACUTE}': 'E', - u'\N{LATIN CAPITAL LETTER E WITH CIRCUMFLEX}': 'E', - u'\N{LATIN CAPITAL LETTER E WITH DIAERESIS}': 'E', - u'\N{LATIN CAPITAL LETTER E WITH GRAVE}': 'E', - u'\N{LATIN CAPITAL LETTER ETH}': 'Th', - u'\N{LATIN CAPITAL LETTER I WITH ACUTE}': 'I', - u'\N{LATIN CAPITAL LETTER I WITH CIRCUMFLEX}': 'I', - u'\N{LATIN CAPITAL LETTER I WITH DIAERESIS}': 'I', - u'\N{LATIN CAPITAL LETTER I WITH GRAVE}': 'I', - u'\N{LATIN CAPITAL LETTER N WITH TILDE}': 'N', - u'\N{LATIN CAPITAL LETTER O WITH ACUTE}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH CIRCUMFLEX}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH DIAERESIS}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH GRAVE}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH STROKE}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH TILDE}': 'O', - u'\N{LATIN CAPITAL LETTER THORN}': 'th', - u'\N{LATIN CAPITAL LETTER U WITH ACUTE}': 'U', - u'\N{LATIN CAPITAL LETTER U WITH CIRCUMFLEX}': 'U', - u'\N{LATIN CAPITAL LETTER U WITH DIAERESIS}': 'U', - u'\N{LATIN CAPITAL LETTER U WITH GRAVE}': 'U', - u'\N{LATIN CAPITAL LETTER Y WITH ACUTE}': 'Y', - u'\N{LATIN SMALL LETTER A WITH ACUTE}': 'a', - u'\N{LATIN SMALL LETTER A WITH CIRCUMFLEX}': 'a', - u'\N{LATIN SMALL LETTER A WITH DIAERESIS}': 'a', - u'\N{LATIN SMALL LETTER A WITH GRAVE}': 'a', - u'\N{LATIN SMALL LETTER A WITH RING ABOVE}': 'a', - u'\N{LATIN SMALL LETTER A WITH TILDE}': 'a', - u'\N{LATIN SMALL LETTER AE}': 'ae', - u'\N{LATIN SMALL LETTER C WITH CEDILLA}': 'c', - u'\N{LATIN SMALL LETTER E WITH ACUTE}': 'e', - u'\N{LATIN SMALL LETTER E WITH CIRCUMFLEX}': 'e', - u'\N{LATIN SMALL LETTER E WITH DIAERESIS}': 'e', - u'\N{LATIN SMALL LETTER E WITH GRAVE}': 'e', - u'\N{LATIN SMALL LETTER ETH}': 'th', - u'\N{LATIN SMALL LETTER I WITH ACUTE}': 'i', - u'\N{LATIN SMALL LETTER I WITH CIRCUMFLEX}': 'i', - u'\N{LATIN SMALL LETTER I WITH DIAERESIS}': 'i', - u'\N{LATIN SMALL LETTER I WITH GRAVE}': 'i', - u'\N{LATIN SMALL LETTER N WITH TILDE}': 'n', - u'\N{LATIN SMALL LETTER O WITH ACUTE}': 'o', - u'\N{LATIN SMALL LETTER O WITH CIRCUMFLEX}': 'o', - u'\N{LATIN SMALL LETTER O WITH DIAERESIS}': 'o', - u'\N{LATIN SMALL LETTER O WITH GRAVE}': 'o', - u'\N{LATIN SMALL LETTER O WITH STROKE}': 'o', - u'\N{LATIN SMALL LETTER O WITH TILDE}': 'o', - u'\N{LATIN SMALL LETTER SHARP S}': 'ss', - u'\N{LATIN SMALL LETTER THORN}': 'th', - u'\N{LATIN SMALL LETTER U WITH ACUTE}': 'u', - u'\N{LATIN SMALL LETTER U WITH CIRCUMFLEX}': 'u', - u'\N{LATIN SMALL LETTER U WITH DIAERESIS}': 'u', - u'\N{LATIN SMALL LETTER U WITH GRAVE}': 'u', - u'\N{LATIN SMALL LETTER Y WITH ACUTE}': 'y', - u'\N{LATIN SMALL LETTER Y WITH DIAERESIS}': 'y', - u'\N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}': '<<', - u'\N{MACRON}': '_', - u'\N{MASCULINE ORDINAL INDICATOR}': '{^o}', - u'\N{MICRO SIGN}': '{micro}', - u'\N{MIDDLE DOT}': '*', - u'\N{MULTIPLICATION SIGN}': '*', - u'\N{NOT SIGN}': '{not}', - u'\N{PILCROW SIGN}': '{paragraph}', - u'\N{PLUS-MINUS SIGN}': '{+/-}', - u'\N{POUND SIGN}': '{pound}', - u'\N{REGISTERED SIGN}': '{R}', - u'\N{RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK}': '>>', - u'\N{SECTION SIGN}': '{section}', - u'\N{SOFT HYPHEN}': '-', - u'\N{SUPERSCRIPT ONE}': '{^1}', - u'\N{SUPERSCRIPT THREE}': '{^3}', - u'\N{SUPERSCRIPT TWO}': '{^2}', - u'\N{VULGAR FRACTION ONE HALF}': '{1/2}', - u'\N{VULGAR FRACTION ONE QUARTER}': '{1/4}', - u'\N{VULGAR FRACTION THREE QUARTERS}': '{3/4}', - u'\N{YEN SIGN}': '{yen}' -} - -def latin1_to_ascii(uinput): - if not isinstance(uinput, unicode): - uinput = unicode(uinput, sys.getfilesystemencoding()) - out = [] - for c in uinput: - i = ord(c) - if i in xlate: - out.append(xlate[i]) - elif i >= 0x80: - pass - else: - out.append(str(c)) - return ''.join(out) - -if __name__ == '__main__': - if len(sys.argv) == 1: - sys.exit('Usage: %s filename\n' % sys.argv[0]) - for name in sys.argv[1:]: - plain_ascii = latin1_to_ascii(name) - if plain_ascii != name: - os.rename(name, plain_ascii) diff --git a/bin/mc_type.py b/bin/mc_type.py index a9d6322..d2e9884 100755 --- a/bin/mc_type.py +++ b/bin/mc_type.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys, subprocess @@ -7,26 +7,30 @@ assert mc in ['/usr/local/bin/mc', '/usr/bin/mc'] mc = subprocess.Popen([mc, '--version'], stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) -mc.wait() -mc_version = mc.stdout.readline() -mc.stdout.read() -mc.stdout.close() + stderr=subprocess.PIPE, + close_fds=True, env={}) +stdout, stderr = mc.communicate() +if mc.returncode or stderr: + sys.exit('Error reading mc version: (%d) %s' % (mc.returncode, stderr)) +if not isinstance(stdout, type('')): + stdout = stdout.decode() +mc_version = stdout.split('\n')[0] if mc_version.startswith('Midnight Commander'): mc_version = mc_version.split()[2] elif mc_version.startswith('GNU Midnight Commander') or \ mc_version.startswith('The Midnight Commander'): mc_version = mc_version.split()[3] else: - raise ValueError('Unknown mc version') + sys.exit('Unknown mc version') + if '.' in mc_version: major, minor = [int(v) for v in mc_version.split('.')[:2]] if major < 4: - print 'old' + print('old') elif (major == 4) and (minor < 6): - print 'old' + print('old') else: - print 'new' + print('new') else: - print 'new' + print('new') diff --git a/bin/m b/bin/mk similarity index 100% rename from bin/m rename to bin/mk diff --git a/bin/mplay b/bin/mplay index e4ca110..decfbfe 100755 --- 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/mv_recode_fname b/bin/mv_recode_fname new file mode 120000 index 0000000..16052c7 --- /dev/null +++ b/bin/mv_recode_fname @@ -0,0 +1 @@ +cp_recode_fname \ No newline at end of file diff --git a/bin/r b/bin/r index 6656358..a0488de 100755 --- a/bin/r +++ b/bin/r @@ -1,2 +1,2 @@ #! /bin/sh -exec rsync -ahP4 "$@" +exec rsync -ahPv "$@" diff --git a/bin/recode-filenames-recursive.py b/bin/recode-filenames-recursive.py index 9afd6c7..5408563 100755 --- a/bin/recode-filenames-recursive.py +++ b/bin/recode-filenames-recursive.py @@ -1,39 +1,57 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys, os -if len(sys.argv) == 3: - start_dir = '.' +from m_lib.defenc import default_encoding + +if len(sys.argv) == 1: + src_encoding = default_encoding + if src_encoding == 'utf-8': + sys.exit("Usage: %s [[src_enc] dst_enc [start_dir]]" % sys.argv[0]) + else: + dst_encoding = 'utf-8' + start_dir = '.' +elif len(sys.argv) == 2: + src_encoding = default_encoding + dst_encoding = sys.argv[1] + start_dir = '.' +elif len(sys.argv) == 3: + src_encoding = default_encoding + dst_encoding = sys.argv[1] + start_dir = sys.argv[2] elif len(sys.argv) == 4: - start_dir = sys.argv[3] + src_encoding = sys.argv[1] + dst_encoding = sys.argv[2] + start_dir = sys.argv[3] else: - sys.exit("Usage: %s src_enc dst_enc [start_dir]" % sys.argv[0]) + sys.exit("Usage: %s [[src_enc] dst_enc [start_dir]]" % sys.argv[0]) - -def _p(plist, dirname, names): - plist.append((dirname, names)) +# Fake for recode_filenames.py +sys.argv = ['', src_encoding, dst_encoding] +from recode_filenames import _recode -plist = [] -os.path.walk(start_dir, _p, plist) -plist.reverse() +def _onerror(exc): + raise exc +plist = list(os.walk(start_dir, topdown=False, onerror=_onerror)) -from recode_filenames import _recode save_dir = os.getcwd() -for dirname, names in plist: - os.chdir(dirname) - for filename in names: - # 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 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) diff --git a/bin/recode-inplace b/bin/recode-inplace index cb8e4e2..77ff306 100755 --- a/bin/recode-inplace +++ b/bin/recode-inplace @@ -1,15 +1,14 @@ #! /bin/sh fromenc="$1" -shift - -toenc="$1" -shift +toenc="$2" +shift 2 tmpfile="`mktemp`" && for file in "$@"; do - iconv -f "$fromenc" -t "$toenc" "$file" >"$tmpfile" && cp "$tmpfile" "$file" + iconv -f "$fromenc" -t "$toenc" "$file" >"$tmpfile" && + cp "$tmpfile" "$file" done exec rm "$tmpfile" diff --git a/bin/recode_filenames.py b/bin/recode_filenames.py index b9b4672..b8d3fa0 100755 --- a/bin/recode_filenames.py +++ b/bin/recode_filenames.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # -*- coding: koi8-r -*- import sys @@ -7,61 +7,63 @@ src_encoding = sys.argv[1] dst_encoding = sys.argv[2] 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 - else: - raise NotImplementedError, "destination encoding must be koi8-r or cp1251, not `%s'" % dst_encoding + 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 + else: + raise NotImplementedError("destination encoding must be koi8-r or cp1251, not `%s'" % dst_encoding) 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 + 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["Ø"] = '' # :-) + 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 + 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 + 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") + from m_lib.opstring import recode + def _recode(s): + return recode(s, src_encoding, dst_encoding, "replace") if __name__ == "__main__": - import os - for filename in sys.argv[3:]: - new_name = _recode(filename) - if new_name <> filename: - os.rename(filename, new_name) + import os + for filename in sys.argv[3:]: + new_name = _recode(filename) + if type(filename) is not type(new_name): + new_name = new_name.decode() + if new_name != filename: + os.rename(filename, new_name) diff --git a/bin/rm-pyc b/bin/rm-pyc index 1f9d7ce..8f51b3c 100755 --- a/bin/rm-pyc +++ b/bin/rm-pyc @@ -1,2 +1,4 @@ #! /bin/sh -exec find . -name '*.py[co]' -delete + +find . -name '*.py[co]' -delete && +exec find . -name __pycache__ -type d -empty -delete diff --git a/bin/rucal b/bin/rucal new file mode 100755 index 0000000..9269dde --- /dev/null +++ b/bin/rucal @@ -0,0 +1,2 @@ +#! /bin/sh +LC_TIME=$LC_CTYPE exec ncal "$@" diff --git a/bin/s b/bin/s index 4f8570d..09649ca 100755 --- a/bin/s +++ b/bin/s @@ -1,2 +1,4 @@ #! /bin/sh -exec ssh -4 "$@" + +ssh "$@"; rc=$? +xtitle && exit $rc diff --git a/bin/screen b/bin/screen index b2fbe11..1b47d5a 100755 --- a/bin/screen +++ b/bin/screen @@ -5,5 +5,6 @@ if [ "$1" = "-ls" -o "$1" = "--list" ]; then fi test "$list" = true || tput smcup -/usr/bin/screen "$@" +/usr/bin/screen "$@"; rc=$? test "$list" = true || tput rmcup +exit $rc diff --git a/bin/screen-defsession b/bin/screen-defsession new file mode 100755 index 0000000..dad9f8b --- /dev/null +++ b/bin/screen-defsession @@ -0,0 +1,11 @@ +#! /bin/sh + +case "$LC_CTYPE" in + *UTF-8) enc_suffix=utf8 + ;; + + *) enc_suffix=koi8 + ;; +esac + +exec screen -xRR -S default-$enc_suffix "$@" diff --git a/bin/smplay b/bin/smplay deleted file mode 100755 index 8561299..0000000 --- a/bin/smplay +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -(xscreensaver-command -exit -xset -dpms s off) & - -b="`basename $0`" - -if [ "$b" = smplay ]; then - GUI="-minigui" -elif [ "$b" = smplay-gui ]; then - GUI="-defaultgui" -else - echo "Bad script name, aborted" 1>&2 - exit 1 -fi - -cgmem_nice 500 smplayer "$GUI" "$@" -"$HOME"/admin/prog/audio-cdr-video/audio/pa-volume - -cd "$HOME" -xset +dpms s on -xscreensaver & diff --git a/bin/smplay-gui b/bin/smplay-gui deleted file mode 120000 index 8c13708..0000000 --- a/bin/smplay-gui +++ /dev/null @@ -1 +0,0 @@ -smplay \ No newline at end of file diff --git a/bin/text-wrap.py b/bin/text-wrap.py index a8e4871..ecfafa8 100755 --- a/bin/text-wrap.py +++ b/bin/text-wrap.py @@ -1,71 +1,73 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 +from __future__ import print_function import sys def usage(code=0): - sys.stderr.write("Usage: %s [-0|--null] [-n|--no-newline] [-s|--space] [-w|--width] [width]\n" % sys.argv[0]) - sys.exit(code) + sys.stderr.write("Usage: %s [-0|--null] [-n|--no-newline] [-s|--space] [-w|--width] [width]\n" % sys.argv[0]) + sys.exit(code) def get_args(): - from getopt import getopt, GetoptError - - try: - options, arguments = getopt(sys.argv[1:], "0nsw:", - ["null", "no-newline", "space", "width="]) - except GetoptError: - usage(1) - - print0 = False - newline = True - space = '' - width = None - - for option, value in options: - if option in ("-h", "--help"): - usage() - elif option in ("-0", "--null"): - print0 = True - elif option in ("-n", "--no-newline"): - newline = False - elif option in ("-s", "--space"): - space = u' ' - elif option in ("-w", "--width"): - width = int(value) - else: - usage(2) - - if arguments: - if width is not None: - usage(3) - elif len(arguments) > 1: - usage(4) - else: - width = int(arguments[0]) - - return print0, newline, space, width + from getopt import getopt, GetoptError + + try: + options, arguments = getopt( + sys.argv[1:], "0nsw:", + ["null", "no-newline", "space", "width="]) + except GetoptError: + usage(1) + + print0 = False + newline = True + space = '' + width = None + + for option, value in options: + if option in ("-h", "--help"): + usage() + elif option in ("-0", "--null"): + print0 = True + elif option in ("-n", "--no-newline"): + newline = False + elif option in ("-s", "--space"): + space = u' ' + elif option in ("-w", "--width"): + width = int(value) + else: + usage(2) + + if arguments: + if width is not None: + usage(3) + elif len(arguments) > 1: + usage(4) + else: + width = int(arguments[0]) + + return print0, newline, space, width print0, newline, space, width = get_args() -from m_lib.defenc import default_encoding -text = sys.stdin.read().decode(default_encoding) +text = sys.stdin.read() if not newline: - text = text.rstrip() + text = text.rstrip() if width: - import textwrap - text = textwrap.fill(text, width - 2*len(space), - initial_indent=space, subsequent_indent=space) - if space: - text = u'\n'.join([line+space for line in text.split(u'\n')]) + import textwrap + text = textwrap.fill( + text, width - 2*len(space), + initial_indent=space, subsequent_indent=space) + if space: + text = u'\n'.join([line+space for line in text.split(u'\n')]) else: - text = u"%s%s%s" % (space, text, space) + text = u"%s%s%s" % (space, text, space) -sys.stdout.write(text.encode(default_encoding)) +sys.stdout.write(text) if print0: - sys.stdout.write('\0') + sys.stdout.write('\0') elif newline: - print + print() diff --git a/bin/unicode_norm_nfd.py b/bin/unicode_norm_nfd.py new file mode 100755 index 0000000..2cca0d9 --- /dev/null +++ b/bin/unicode_norm_nfd.py @@ -0,0 +1,23 @@ +#! /usr/bin/env python3 +# https://stackoverflow.com/a/518232/7976758 + +import sys +import unicodedata + + +def strip_accents(s): + return ''.join(c for c in unicodedata.normalize('NFD', s) + if unicodedata.category(c) != 'Mn') + + +def latin1_to_ascii(uinput): + if isinstance(uinput, bytes): + uinput = uinput.decode(sys.getfilesystemencoding()) + return strip_accents(uinput) + + +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)) diff --git a/bin/unzip.py b/bin/unzip.py index 42bf4db..57af7b1 100755 --- a/bin/unzip.py +++ b/bin/unzip.py @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Unzip with encoded filenames - Written by Oleg Broytman. Copyright (C) 2009-2016 PhiloSoft Design. + Written by Oleg Broytman. Copyright (C) 2009-2024 PhiloSoft Design. """ import sys, os, time @@ -26,10 +26,11 @@ out = '.' for zinfo in zf.infolist(): path = zinfo.filename - if not isinstance(path, unicode): - path = path.decode('cp866') - recoded_path = path.encode(default_encoding) - print recoded_path + if isinstance(path, bytes): + recoded_path = path.decode('cp866').encode(default_encoding) + else: + recoded_path = path + print(recoded_path) if path.startswith('./'): recoded_path = recoded_path[2:] diff --git a/bin/webbrowser b/bin/webbrowser index 0590aa0..a4c2024 100755 --- a/bin/webbrowser +++ b/bin/webbrowser @@ -1,27 +1,52 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys, os # This must be imported and called before webbrowser # because webbrowser reads BROWSER environment variable at the import time from browser_stack import set_current_browser -set_current_browser() +browser = set_current_browser() + +if sys.argv[1] in ("-p", "--private", "--incognito"): + try: + url = sys.argv[2] + except IndexError: + url = '' + if browser == 'firefox': + if url: + os.system('firefox --private-window "%s"' % url) + else: + os.system('firefox --private-window') + sys.exit() + elif browser in ("google-chrome", "chrome", "chromium", "chromium-browser"): + os.system('%s --incognito "%s"' % (browser, url)) + sys.exit() + sys.exit("Unsupported browser") import webbrowser if sys.argv[1] in ("-t", "--tab"): - new = 2 - url = sys.argv[2] + new = 2 + try: + url = sys.argv[2] + except IndexError: + url = '' elif sys.argv[1] in ("-n", "--new"): - new = 1 - url = sys.argv[2] + new = 1 + try: + url = sys.argv[2] + except IndexError: + url = '' else: - new = 0 - url = sys.argv[1] + new = 0 + try: + url = sys.argv[1] + except IndexError: + url = '' -if '://' not in url: # Make an URL from a local file name +if url and '://' not in url: # Make an URL from a local file name url = 'file://' + os.path.abspath(url) webbrowser.open(url, new) diff --git a/bin/webbrowser-encode-url b/bin/webbrowser-encode-url index 2dc183f..e30b6ff 100755 --- a/bin/webbrowser-encode-url +++ b/bin/webbrowser-encode-url @@ -1,8 +1,9 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 -from cgi import parse_qsl from getopt import getopt, GetoptError -import sys, urllib +from urllib.parse import urlsplit, parse_qsl, quote, quote_plus, urlencode +import sys + from m_lib.defenc import default_encoding # This must be imported and called before webbrowser @@ -10,17 +11,21 @@ from m_lib.defenc import default_encoding from browser_stack import set_current_browser set_current_browser() -import webbrowser +import webbrowser # noqa: E402 module level import not at top of file + def usage(): - sys.exit('Usage: %s [-e|--encoding=encoding] [-n|--newwin|-t|--tab] URL' % sys.argv[0]) + sys.exit('Usage: %s [-e|--encoding=encoding] [-n|--newwin|-t|--tab] URL' + % sys.argv[0]) + try: - options, arguments = getopt(sys.argv[1:], 'e:nt', ['encoding=', 'newwin', 'tab']) + options, arguments = getopt( + sys.argv[1:], 'e:nt', ['encoding=', 'newwin', 'tab']) except GetoptError: usage() -if len(arguments) <> 1: +if len(arguments) != 1: usage() encoding = None @@ -38,45 +43,52 @@ if not encoding: encoding = default_encoding url = arguments[0] -protocol, request = urllib.splittype(url) -user, password, port = None, None, None -host, path = urllib.splithost(request) -if host: - user, host = urllib.splituser(host) - if user: - user, password = urllib.splitpasswd(user) - host, port = urllib.splitport(host) - if port: port = int(port) -path, tag = urllib.splittag(path) -path, query = urllib.splitquery(path) -path = urllib.unquote(path) -if tag: tag = urllib.unquote_plus(tag) + +split_results = urlsplit(url) +protocol, netloc, path, query, tag = split_results +user = split_results.username +password = split_results.password +host = split_results.hostname +port = split_results.port if query: - qlist = [] - for name, value in parse_qsl(query): - name = unicode(name, default_encoding).encode(encoding) - value = unicode(value, default_encoding).encode(encoding) - qlist.append((name, value)) + qlist = [] + for name, value in parse_qsl(query): + if isinstance(name, bytes): + name = name.decode(default_encoding) + value = value.decode(default_encoding) + name = name.encode(encoding) + value = value.encode(encoding) + qlist.append((name, value)) url = protocol + "://" if user: - url += urllib.quote(unicode(user, default_encoding).encode(encoding)) - if password: - url += ':' + urllib.quote(unicode(password, default_encoding).encode(encoding)) - url += '@' + if isinstance(user, bytes): + user = user.decode(default_encoding) + url += quote(user.encode(encoding)) + if password: + if isinstance(password, bytes): + password = password.decode(default_encoding) + url += ':' + quote(password.encode(encoding)) + url += '@' if host: - url += host.decode(encoding).encode('idna') - if port: - url += ':%d' % port + if isinstance(host, bytes): + host = host.decode(encoding) + url += host.encode('idna').decode('ascii') + if port: + url += ':%d' % port if path: - if protocol == "file": - url += urllib.quote(path) - else: - url += urllib.quote(unicode(path, default_encoding).encode(encoding)) + if protocol == "file": + url += quote(path) + else: + if isinstance(path, bytes): + path = path.decode(default_encoding) + url += quote(path.encode(encoding)) if query: - url += '?' + urllib.urlencode(qlist) + url += '?' + urlencode(qlist) if tag: - url += '#' + urllib.quote_plus(unicode(tag, default_encoding).encode(encoding)) + if isinstance(tag, bytes): + tag = tag.decode(default_encoding) + url += '#' + quote_plus(tag.encode(encoding)) webbrowser.open(url, new) diff --git a/bin/webstdin b/bin/webstdin index 395456c..209cecf 100755 --- a/bin/webstdin +++ b/bin/webstdin @@ -13,4 +13,4 @@ done shift `expr $OPTIND - 1` tmpfile="`mktemp -t XXXXXX.$ext`" && cat - >"$tmpfile" && -webbrowser $new_win file://"$tmpfile" && (sleep 10 && exec rm "$tmpfile" &) +webbrowser $new_win file://"$tmpfile"