basic structure; zsh default; no desktop assumed

This commit is contained in:
Daniil Fajnberg 2021-11-14 11:40:27 +01:00
commit 1280d2360d
21 changed files with 1157 additions and 0 deletions

3
_custom/.local/bin/pdfmerge Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
outputfile=$1 && shift
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=${outputfile} $@

17
_custom/.local/bin/pdfsection Executable file
View File

@ -0,0 +1,17 @@
#!/bin/zsh
# Extract a page range from a PDF file
# 1 original PDF file path
# 2 first page of desired range
# 3 last page of desired range (optional)
source ~/.local/lib/pdf_tools.sh
typeset -r numpages=$(pdf_num_pages $1)
typeset -r digits=$#numpages
typeset -r -Z${digits} first=$2
typeset -Z${digits} last=${numpages}
if (( $# >= 3 )); then
(( $3 > ${numpages} )) && echo "The document is only ${numpages} pages long, which is less than $3!" && exit 1
last=$3
fi
pdf_extract_range "$1" $2 $3 "${1%.pdf}_${first}-${last}.pdf" > /dev/null

18
_custom/.local/bin/pdfspagewise Executable file
View File

@ -0,0 +1,18 @@
#!/bin/zsh
# Split up a PDF pagewise
source ~/.local/lib/pdf_tools.sh
typeset -r numpages=$(pdf_num_pages $1)
((numpages == 1)) && echo "PDF file has only one page. No action taken." && exit
echo Processing ${numpages} pages...
typeset -r digits=$#numpages
typeset -Z${digits} page=1
while ((page <= numpages)); do
pdf_extract_range "$1" ${page} ${page} "${1%.pdf}_${page}.pdf" > /dev/null
((page = page + 1))
done
echo Done.

19
_custom/.local/bin/pdfsplit Executable file
View File

@ -0,0 +1,19 @@
#!/bin/zsh
# Split a PDF file in two at a specified page
# 1 original PDF file path
# 2 last page of first section (second section will start with the one after that)
source ~/.local/lib/pdf_tools.sh
typeset -r numpages=$(pdf_num_pages $1)
typeset -r digits=$#numpages
typeset -r -Z${digits} m=$2
(( $2 > ${numpages} )) && echo "The document is only ${numpages} pages long, which is less than $2!" && exit 1
(( $2 == ${numpages} )) && echo "The document is exactly ${numpages} pages long!\nNo action taken." && exit
typeset -r stem=${1%.pdf}
typeset -r -Z${digits} one=1
typeset -r -Z${digits} n=$(( m + 1 ))
pdf_extract_range "$1" 1 ${m} "${stem}_${one}-${m}.pdf" > /dev/null
pdf_extract_range "$1" ${n} ${numpages} "${stem}_${n}-${numpages}.pdf" > /dev/null

144
_custom/.local/bin/ssh-tun Executable file
View File

@ -0,0 +1,144 @@
#!/usr/bin/env python3
"""
Convenience wrapper for SSH tunnel creation and control.
Allows spawning and exiting SSH tunnel processes in the background easily.
Reverse tunnels work too. (see help text)
Currently only supports port-based forwarding, no sockets.
Example usage:
$ ssh-tun user@hostname start 8000 9020
Sets up a forwarding tunnel at user@hostname from local port 8000 to remote port 9020.
$ ssh-tun user@hostname check
Returns the PID of the tunnel to user@hostname (if one exists)
$ ssh-tun user@hostname stop
Exits the process of the tunnel to user@hostname (if one is running)
More help:
$ ssh-tun -h
"""
from argparse import ArgumentParser, Namespace
from pathlib import Path
from subprocess import run
# Mandatory always:
DESTINATION = 'destination'
# Optional to specify control socket:
CTL_SOCK_PATH, CTL_SOCK_PATH_SHORT = 'control_socket_path', 'S'
CTL_SOCK_DEFAULT_FILE_NAME = '.ssh-tunnel-ctl'
CTL_SOCK_PATH_DEFAULT = Path(Path(), CTL_SOCK_DEFAULT_FILE_NAME)
# Sub-commands:
CMD = 'cmd'
START, CHECK, STOP = 'start', 'check', 'stop'
# Mandatory for starting:
PORT, HOSTPORT = 'entry_port', 'exit_port'
# Optional for starting:
BIND_ADDRESS, BIND_ADDRESS_SHORT = 'bind_address', 'b'
HOST, HOST_SHORT = 'host', 'H'
REVERSE, REVERSE_SHORT = 'reverse', 'R'
# SSH constants:
SSH = 'ssh'
CON_CTL_CMD = 'ctl_cmd'
CON_CTL_CMD_SHORT = 'O'
CTL_CHECK = 'check'
CTL_EXIT = 'exit'
FORWARD_SHORT = 'L'
TUNNEL_FLAGS = 'fNM' # run in the background (f), don't execute remote command (N), and use "master" mode (M)
def main() -> None:
parser = ArgumentParser(description="Work with ssh tunnels in the background")
parser.add_argument(
DESTINATION,
help="The destination that ssh is supposed to connect to, e.g. `[user@]hostname`"
)
parser.add_argument(
f'-{CTL_SOCK_PATH_SHORT}', f'--{CTL_SOCK_PATH.replace("_", "-")}',
type=Path,
default=CTL_SOCK_PATH_DEFAULT,
help=f"Specifies the location of a control socket; defaults to {CTL_SOCK_PATH_DEFAULT}"
)
sub_parsers = parser.add_subparsers(dest=CMD)
# Starting a new tunnel:
parser_start = sub_parsers.add_parser(START, help="Start a new ssh tunnel")
parser_start.add_argument(
PORT,
help="The entry port of the tunnel (called `port` in the ssh manual)"
)
parser_start.add_argument(
HOSTPORT,
help="The exit port of the tunnel (called `hostport` in the ssh manual)"
)
parser_start.add_argument(
f'-{HOST_SHORT}', f'--{HOST}',
default='localhost',
help="The host to connect to at the tunnel exit; defaults to `localhost`"
)
parser_start.add_argument(
f'-{BIND_ADDRESS_SHORT}', f'--{BIND_ADDRESS.replace("_", "-")}',
help="The address to listen to at the tunnel entrance. When doing regular forwarding, by default the local "
"port is bound in accordance with the GatewayPorts setting; when doing reverse forwarding listening "
"socket on the server will be bound to the loopback interface only."
)
parser_start.add_argument(
f'-{REVERSE_SHORT}', f'--{REVERSE}',
action='store_true',
help="If set, a reverse tunnel is created, where connections to the given TCP port on the remote (server) host "
"are to be forwarded to the local side; if not set, connections to the given TCP port on the local "
"(client) host are to be forwarded to the given host and port on the remote side."
)
parser_start.set_defaults(func=handle_start)
parser_check = sub_parsers.add_parser(CHECK, help="Check the status of an existing ssh tunnel")
parser_check.set_defaults(func=handle_check)
parser_stop = sub_parsers.add_parser(STOP, help="Close an existing ssh tunnel")
parser_stop.set_defaults(func=handle_stop)
args = parser.parse_args()
try:
args.func(args)
except AttributeError:
print("Command not specified! \n")
parser.parse_args([])
def handle_start(args: Namespace) -> None:
args = vars(args)
tunnel_spec = f'{args[PORT]}:{args[HOST]}:{args[HOSTPORT]}'
if args[BIND_ADDRESS]:
tunnel_spec = f"{args[BIND_ADDRESS]}:{tunnel_spec}"
tunnel_type = f'-{REVERSE_SHORT if args[REVERSE] else FORWARD_SHORT}'
run([
SSH,
tunnel_type, tunnel_spec,
f'-{TUNNEL_FLAGS}',
f'-{CTL_SOCK_PATH_SHORT}', args[CTL_SOCK_PATH],
args[DESTINATION]
])
def handle_check(args: Namespace) -> None:
setattr(args, CON_CTL_CMD, CTL_CHECK)
_handle_control(args)
def handle_stop(args: Namespace) -> None:
setattr(args, CON_CTL_CMD, CTL_EXIT)
_handle_control(args)
def _handle_control(args: Namespace) -> None:
args = vars(args)
run([
SSH,
f'-{CTL_SOCK_PATH_SHORT}', args[CTL_SOCK_PATH],
f'-{CON_CTL_CMD_SHORT}', args[CON_CTL_CMD],
args[DESTINATION]
])
if __name__ == '__main__':
main()

2
_custom/.local/bin/videoconcat Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
ffmpeg -safe 0 -f concat -i <(find . -type f -name "$1*" -printf "file '$PWD/%p'\n" | sort) -c copy $2

View File

@ -0,0 +1,8 @@
#!/bin/zsh
function pdf_num_pages {
gs -q -dNOSAFER -dNODISPLAY -c "($1) (r) file runpdfbegin pdfpagecount = quit"
}
function pdf_extract_range {
yes | gs -q -dBATCH -sOutputFile="$4" -dFirstPage=$2 -dLastPage=$3 -sDEVICE=pdfwrite "$1"
}

191
git/.config/git/config Normal file
View File

@ -0,0 +1,191 @@
# Source: https://github.com/mathiasbynens/dotfiles/
[alias]
# View abbreviated SHA, description, and history graph of the latest 20 commits.
l = log --pretty=oneline -n 20 --graph --abbrev-commit
# View the current working tree status using the short format.
s = status -s
# Show the diff between the latest commit and the current state.
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
# `git di $number` shows the diff between the state `$number` revisions ago and the current state.
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
# Pull in remote changes for the current repository and all its submodules.
p = pull --recurse-submodules
# Clone a repository including all submodules.
c = clone --recursive
# Commit all changes.
ca = !git add -A && git commit -av
# Switch to a branch, creating it if necessary.
go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f"
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch --all
remotes = remote --verbose
# List aliases.
aliases = config --get-regexp alias
# Amend the currently staged files to the latest commit.
amend = commit --amend --reuse-message=HEAD
# Credit an author on the latest commit.
credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f"
# Interactive rebase with the given number of latest commits.
reb = "!r() { git rebase -i HEAD~$1; }; r"
# Remove the old tag with this name and tag the latest commit with it.
retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r"
# Find branches containing commit
fb = "!f() { git branch -a --contains $1; }; f"
# Find tags containing commit
ft = "!f() { git describe --always --contains $1; }; f"
# Find commits by source code
fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f"
# Find commits by commit message
fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f"
# Remove branches that have already been merged with main.
# a.k.a. delete merged
dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# List contributors with number of commits.
contributors = shortlog --summary --numbered
# Show the user email for the current repository.
whoami = config user.email
[apply]
# Detect whitespace errors when applying a patch.
whitespace = fix
[branch]
# Show most recently changed branches first.
sort = -committerdate
[core]
# Use custom `.gitignore` and `.gitattributes`.
excludesfile = ~/.gitignore
attributesfile = ~/.gitattributes
# Treat spaces before tabs and all kinds of trailing whitespace as an error.
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
# Make `git rebase` safer on macOS.
# More info: <http://www.git-tower.com/blog/make-git-rebase-safe-on-osx/>
trustctime = false
# Prevent showing files whose names contain non-ASCII symbols as unversioned.
# http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html
precomposeunicode = false
# Speed up commands involving untracked files such as `git status`.
# https://git-scm.com/docs/git-update-index#_untracked_cache
untrackedCache = true
[color]
# Use colors in Git commands that are capable of colored output when
# outputting to the terminal. (This is the default setting in Git ≥ 1.8.4.)
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold # line info
old = red # deletions
new = green # additions
[color "status"]
added = yellow
changed = green
untracked = cyan
[commit]
# https://help.github.com/articles/signing-commits-using-gpg/
#gpgsign = true
[diff]
# Detect copies as well as renames.
renames = copies
[diff "bin"]
# Use `hexdump` to diff binary files.
textconv = hexdump -v -C
[help]
# Automatically correct and execute mistyped commands.
autocorrect = 1
[merge]
# Include summaries of merged commits in newly created merge commit messages
log = true
tool = emerge
[push]
# https://git-scm.com/docs/git-config#git-config-pushdefault
default = simple
# Make `git push` push relevant annotated tags when pushing branches out.
followTags = true
[submodule]
recurse = true
# URL shorthands
[url "git@github.com:"]
insteadOf = "gh:"
pushInsteadOf = "github:"
pushInsteadOf = "git://github.com/"
[url "git://github.com/"]
insteadOf = "github:"
[url "git@gist.github.com:"]
insteadOf = "gst:"
pushInsteadOf = "gist:"
pushInsteadOf = "git://gist.github.com/"
[url "git://gist.github.com/"]
insteadOf = "gist:"
[init]
defaultBranch = master

160
mc/.config/mc/ini Normal file
View File

@ -0,0 +1,160 @@
[Midnight-Commander]
verbose=true
shell_patterns=true
auto_save_setup=true
preallocate_space=false
auto_menu=false
use_internal_view=true
use_internal_edit=false
clear_before_exec=true
confirm_delete=true
confirm_overwrite=true
confirm_execute=false
confirm_history_cleanup=true
confirm_exit=false
confirm_directory_hotlist_delete=false
confirm_view_dir=false
safe_delete=false
safe_overwrite=false
use_8th_bit_as_meta=false
mouse_move_pages_viewer=true
mouse_close_dialog=false
fast_refresh=false
drop_menus=false
wrap_mode=false
old_esc_mode=true
cd_symlinks=true
show_all_if_ambiguous=true
use_file_to_guess_type=true
alternate_plus_minus=false
only_leading_plus_minus=true
show_output_starts_shell=false
xtree_mode=false
file_op_compute_totals=true
classic_progressbar=true
use_netrc=true
ftpfs_always_use_proxy=false
ftpfs_use_passive_connections=true
ftpfs_use_passive_connections_over_proxy=false
ftpfs_use_unix_list_options=true
ftpfs_first_cd_then_ls=true
ignore_ftp_chattr_errors=true
editor_fill_tabs_with_spaces=false
editor_return_does_auto_indent=true
editor_backspace_through_tabs=false
editor_fake_half_tabs=true
editor_option_save_position=true
editor_option_auto_para_formatting=false
editor_option_typewriter_wrap=false
editor_edit_confirm_save=true
editor_syntax_highlighting=true
editor_persistent_selections=true
editor_drop_selection_on_copy=true
editor_cursor_beyond_eol=false
editor_cursor_after_inserted_block=false
editor_visible_tabs=true
editor_visible_spaces=true
editor_line_state=false
editor_simple_statusbar=false
editor_check_new_line=false
editor_show_right_margin=false
editor_group_undo=false
editor_state_full_filename=false
editor_ask_filename_before_edit=false
nice_rotating_dash=true
mcview_remember_file_position=false
auto_fill_mkdir_name=true
copymove_persistent_attr=true
pause_after_run=1
mouse_repeat_rate=100
double_click_speed=250
old_esc_mode_timeout=1000000
max_dirt_limit=10
num_history_items_recorded=60
vfs_timeout=60
ftpfs_directory_timeout=900
ftpfs_retry_seconds=30
fish_directory_timeout=900
editor_tab_spacing=8
editor_word_wrap_line_length=72
editor_option_save_mode=0
editor_backup_extension=~
editor_filesize_threshold=64M
editor_stop_format_chars=-+*\\,.;:&>
mcview_eof=
skin=yadt256-defbg
shadows=true
[Layout]
output_lines=0
left_panel_size=115
top_panel_size=0
message_visible=true
keybar_visible=true
xterm_title=true
command_prompt=true
menubar_visible=true
free_space=true
horizontal_split=false
vertical_equal=true
horizontal_equal=true
[Misc]
timeformat_recent=%d. %b %H:%M
timeformat_old=%d. %b %Y
ftp_proxy_host=gate
ftpfs_password=anonymous@
display_codepage=ASCII
source_codepage=Other_8_bit
autodetect_codeset=
clipboard_store=
clipboard_paste=
[Colors]
base_color=
st-256color=
color_terminals=
[Panels]
show_mini_info=true
kilobyte_si=true
mix_all_files=false
show_backups=true
show_dot_files=true
fast_reload=false
fast_reload_msg_shown=false
mark_moves_down=true
reverse_files_only=true
auto_save_setup_panels=false
navigate_with_arrows=true
panel_scroll_pages=true
panel_scroll_center=false
mouse_move_pages=true
filetype_mode=true
permission_mode=false
torben_fj_mode=false
quick_search_mode=2
select_flags=6
simple_swap=false
[FindFile]
file_case_sens=true
file_shell_pattern=true
file_find_recurs=true
file_skip_hidden=false
file_all_charsets=false
content_case_sens=true
content_regexp=false
content_first_hit=false
content_whole_words=false
content_all_charsets=false
ignore_dirs_enable=true
ignore_dirs=
[Panelize]
Geänderte Git-Dateien=git ls-files --modified
Nach dem Patchen nach Ablehnungen suchen=find . -name \\*.rej -print
Suche SUID- und SGID-Programme=find . \\( \\( -perm -04000 -a -perm /011 \\) -o \\( -perm -02000 -a -perm /01 \\) \\) -print
Suche nach *.orig nach dem Patchen=find . -name \\*.orig -print

387
mc/.config/mc/menu Normal file
View File

@ -0,0 +1,387 @@
shell_patterns=0
##############################################################################
# %% The % character
# %f The current file (if non-local vfs, file will be copied locally and
# %f will be full path to it)
# %p The current file
# %d The current working directory
# %s "Selected files"; the tagged files if any, otherwise the current file
# %t Tagged files
# %u Tagged files (and they are untagged on return from expand_format)
# %view Runs the commands and pipes standard output to the view command
# If %view is immediately followed by '{', recognize keywords
# ascii, hex, nroff and unform
#
# If the format letter is in uppercase, it refers to the other panel
#
# With a number followed the % character you can turn quoting on (default)
# and off. For example:
# %f quote expanded macro
# %1f ditto
# %0f don't quote expanded macro
##############################################################################
+ ! t t
@ Do something on the current file
CMD=%{Enter command}
$CMD %f
+ t t
@ Do something on the tagged files
CMD=%{Enter command}
for i in %t ; do
$CMD "$i"
done
0 Edit a bug report and send it to root
I=`mktemp "${MC_TMPDIR:-/tmp}/mail.XXXXXX"` || exit 1
${EDITOR-vi} "$I"
test -r "$I" && mail root < "$I"
rm -f "$I"
=+ f \.1$ | f \.3$ | f \.4$ | f \.5$ | f \.6$ | f \.7$ | f \.8$ | f \.man$ & t r
1 Display the file with roff -man
%view{ascii,nroff} roff -c -Tlatin1 -mandoc %f
2 Call the info hypertext browser
info
= t d
3 Compress the current subdirectory (tar.gz)
Pwd=`basename %d /`
echo -n "Name of the compressed file (without extension) [$Pwd]: "
read tar
[ "$tar"x = x ] && tar="$Pwd"
cd .. && \
tar cf - "$Pwd" | gzip -f9 > "$tar.tar.gz" && \
echo "../$tar.tar.gz created."
4 Compress the current subdirectory (tar.bz2)
Pwd=`basename %d /`
echo -n "Name of the compressed file (without extension) [$Pwd]: "
read tar
[ "$tar"x = x ] && tar="$Pwd"
cd .. && \
tar cf - "$Pwd" | bzip2 -f > "$tar.tar.bz2" && \
echo "../$tar.tar.bz2 created."
5 Compress the current subdirectory (tar.7z)
Pwd=`basename %d /`
echo -n "Name of the compressed file (without extension) [$Pwd]: "
read tar
[ "$tar"x = x ] && tar="$Pwd"
cd .. && \
tar cf - "$Pwd" | 7za a -si "$tar.tar.7z" && \
echo "../$tar.tar.7z created."
6 Compress the current subdirectory (tar.xz)
Pwd=`basename %d /`
echo -n "Name of the compressed file (without extension) [$Pwd]: "
read tar
[ "$tar"x = x ] && tar="$Pwd"
cd .. && \
tar cf - "$Pwd" | xz -f > "$tar.tar.xz" && \
echo "../$tar.tar.xz created."
7 Compress the current subdirectory (tar.zst)
Pwd=`basename %d /`
echo -n "Name of the compressed file (without extension) [$Pwd]: "
read tar
[ "$tar"x = x ] && tar="$Pwd"
cd .. && \
tar cf - "$Pwd" | zstd -f > "$tar.tar.zst" && \
echo "../$tar.tar.zst created."
I Open directory with image viewer
sxiv %d
V Open directory with video player
mpv %d
= f \.c$ & t r
+ f \.c$ & t r & ! t t
c Compile and link current .c file
make "`basename %f .c`" 2>/dev/null || cc -O -o "`basename %f .c`" %f
+ t r & ! t t
a Append file to opposite
cat %f >> %D/%f
+ t t
A Append files to opposite files
for i in %t ; do
cat "$i" >> %D/"$i"
done
+ t r & ! t t
d Delete file if a copy exists in the other directory.
if [ %d = %D ]; then
echo "The two directories must be different."
exit 1
fi
if [ -f %D/%f ]; then # if two of them, then
if cmp -s %D/%f %f; then
rm %f && echo %f": DELETED."
else
echo %f" and "%D/%f" differ: NOT deleted."
echo -n "Press RETURN "
read key
fi
else
echo %f": No copy in "%D/%f": NOT deleted."
fi
+ t t
D Delete tagged files if a copy exists in the other directory.
if [ %d = %D ]; then
echo "The two directores must be different."
exit 1
fi
for i in %t ; do
if [ -f %D/"$i" ]; then
SUM1=`sum "$i"`
SUM2=`sum %D/"$i"`
if [ "$SUM1" = "$SUM2" ]; then
rm "$i" && echo "${i}: DELETED."
else
echo "$i and "%D"/$i differ: NOT deleted."
fi
else
echo "$i has no copy in "%D": NOT deleted."
fi
done
m View manual page
MAN=%{Enter manual name}
%view{ascii,nroff} MANROFFOPT='-c -Tlatin1' MAN_KEEP_FORMATTING=1 man -P cat "$MAN"
= f \.gz$ & t r
+ ! t t
n Inspect gzip'ed newsbatch file
dd if=%f bs=1 skip=12 | zcat | ${PAGER-more}
# assuming the cunbatch header is 12 bytes long.
= t r &
+ ! t t
h Strip headers from current newsarticle
CHECK=`awk '{print $1 ; exit}' %f` 2>/dev/null
case "$CHECK" in
Newsgroups:|Path:)
I=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
cp %f "$I" && sed '/^'"$CHECK"' /,/^$/d' "$I" > %f
[ "$?" = "0" ] && rm "$I"
echo %f": header removed."
;;
*)
echo %f" is not a news article."
;;
esac
+ t t
H Strip headers from the marked newsarticles
for i in %t ; do
CHECK=`awk '{print $1 ; exit}' "$i"` 2>/dev/null
WFILE=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
case "$CHECK" in
Newsgroups:|Path:)
cp "$i" "$WFILE" && sed '/^'"$CHECK"' /,/^$/d' "$WFILE" > "$i"
if [ "$?" = "0" ]; then
rm "$WFILE"; echo "$i header removed. OK."
else
echo "Oops! Please check $i against $WFILE."
fi
;;
*)
echo "$i skipped: Not a news article."
;;
esac
done
=+ f \.jpg$ | f \.JPG$ | \.png$ | \.PNG$ & (t r | t l)
i Open with image viewer
sxiv %f
=+ f \.pdf$ | f \.PDF$ & (t r | t l)
p Open with PDF viewer
zathura %f
=+ f \.mp4$ | f \.MP4$ | \.m4v$ | \.M4V$ | \.mkv$ | \.MKV$ | \.avi$ | \.AVI$ | \.mpg$ | \.MPG$ | \.webm$ & (t r | t l)
v Open with video player
mpv %f
= t r
+ ! t t
r Copy file to remote host
echo -n "To which host?: "
read Host
echo -n "To which directory on $Host?: "
read Dir
rcp -p %f "${Host}:${Dir}"
+ t t
R Copy files to remote host (no error checking)
echo -n "Copy files to which host?: "
read Host
echo -n "To which directory on $Host? :"
read Dir
rcp -pr %u "${Host}:${Dir}"
= f \.tex$ & t r
+ f \.tex$ & t r & ! t t
t Run latex on file and show it with xdvi
latex %f && xdvi "`basename %f .tex`".dvi
=+ f ^part | f ^Part | f uue & t r
+ t t
U Uudecode marked news articles (needs work)
(
for i in %t ; do # strip headers
FIRST=`awk '{print $1 ; exit}' "$i"`
cat "$i" | sed '/^'"$FIRST"' /,/^$/d'
done
) | sed '/^$/d' | sed -n '/^begin 6/,/^end$/p' | uudecode
if [ "$?" != "0" ]; then
echo "Cannot decode "%t"."
fi
echo "Please test the output file before deleting anything."
=+ f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.tar\.zst | f \.tar\.Z$ | f \.tar\.bz2$ & t rl
x Extract the contents of a compressed tar file
unset PRG
case %f in
*.tar.7z) PRG="7za e -so";;
*.tar.bz2) PRG="bunzip2 -c";;
*.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z) PRG="gzip -dc";;
*.tar.lz) PRG="lzip -dc";;
*.tar.lz4) PRG="lz4 -dc";;
*.tar.lzma) PRG="lzma -dc";;
*.tar.xz) PRG="xz -dc";;
*.tar.zst) PRG="zstd -dc";;
*) exit 1;;
esac
$PRG %f | tar xvf -
= t r
+ ! t t
y Gzip or gunzip current file
unset DECOMP
case %f in
*.gz|*.[zZ]) DECOMP=-d;;
esac
# Do *not* add quotes around $DECOMP!
gzip $DECOMP -v %f
+ t t
Y Gzip or gunzip tagged files
for i in %t ; do
unset DECOMP
case "$i" in
*.gz|*.[zZ]) DECOMP=-d;;
esac
gzip $DECOMP -v "$i"
done
+ ! t t
b Bzip2 or bunzip2 current file
unset DECOMP
case %f in
*.bz2) DECOMP=-d;;
esac
bzip2 $DECOMP -v %f
+ t t
B Bzip2 or bunzip2 tagged files
for i in %t ; do
unset DECOMP
case "$i" in
*.bz2) DECOMP=-d;;
esac
bzip2 $DECOMP -v "$i"
done
+ f \.tar.gz$ | f \.tgz$ | f \.tpz$ | f \.tar.Z$ | f \.tar.z$ | f \.tar.bz2$ | f \.tar.F$ & t r & ! t t
z Extract compressed tar file to subdirectory
unset D
set gzip -cd
case %f in
*.tar.F) D=`basename %f .tar.F`; set freeze -dc;;
*.tar.Z) D=`basename %f .tar.Z`;;
*.tar.bz2) D=`basename %f .tar.bz2`; set bunzip2 -c;;
*.tar.gz) D=`basename %f .tar.gz`;;
*.tar.z) D=`basename %f .tar.z`;;
*.tgz) D=`basename %f .tgz`;;
*.tpz) D=`basename %f .tpz`;;
esac
mkdir "$D"; cd "$D" && ("$1" "$2" ../%f | tar xvf -)
+ t t
Z Extract compressed tar files to subdirectories
for i in %t ; do
set gzip -dc
unset D
case "$i" in
*.tar.F) D=`basename "$i" .tar.F`; set freeze -dc;;
*.tar.Z) D=`basename "$i" .tar.Z`;;
*.tar.bz2) D=`basename "$i" .tar.bz2`; set bunzip2 -c;;
*.tar.gz) D=`basename "$i" .tar.gz`;;
*.tar.z) D=`basename "$i" .tar.z`;;
*.tgz) D=`basename "$i" .tgz`;;
*.tpz) D=`basename "$i" .tpz`;;
esac
mkdir "$D"; (cd "$D" && "$1" "$2" "../$i" | tar xvf -)
done
+ f \.gz$ | f \.tgz$ | f \.tpz$ | f \.Z$ | f \.z$ | f \.bz2$ & t r & ! t t
c Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
unset D
unset EXT
case %f in
*.Z) EXT=Z;;
*.bz2) EXT=bz2;;
*.gz) EXT=gz;;
*.tgz) EXT=tgz;;
*.tpz) EXT=tpz;;
*.z) EXT=z;;
esac
case "$EXT" in
bz2|Z|gz|z) D=`basename %f ."$EXT"`;;
tgz|tpz) D=`basename %f ."$EXT"`.tar;;
esac
if [ "$EXT" = "bz2" ]; then
bunzip2 -v %f
gzip -f9 -v "$D"
else
gunzip -v %f
bzip2 -v "$D"
fi
+ t t
C Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
for i in %t ; do
unset D
unset EXT
case "$i" in
*.Z) EXT=Z;;
*.bz2) EXT=bz2;;
*.gz) EXT=gz;;
*.tgz) EXT=tgz;;
*.tpz) EXT=tpz;;
*.z) EXT=z;;
esac
case "$EXT" in
bz2|Z|gz|z) D=`basename "$i" ."$EXT"`;;
tgz|tpz) D=`basename "$i" ."$EXT"`.tar;;
esac
if [ "$EXT" = "bz2" ]; then
bunzip2 -v "$i"
gzip -f9 -v "$D"
else
gunzip -v "$i"
bzip2 -v "$D"
fi
done
+ x /usr/bin/open | x /usr/local/bin/open & x /bin/sh
o Open next a free console
open -s -- sh

35
mc/.config/mc/panels.ini Normal file
View File

@ -0,0 +1,35 @@
[New Left Panel]
display=listing
reverse=false
case_sensitive=true
exec_first=false
sort_order=name
list_mode=full
brief_cols=2
user_format=half type name | size | perm | mtime
user_status0=half type name | size | perm
user_status1=half type name | size | perm
user_status2=half type name | size | perm
user_status3=half type name | owner | group | ctime
user_mini_status=true
list_format=user
[New Right Panel]
display=listing
reverse=false
case_sensitive=true
exec_first=false
sort_order=name
list_mode=full
brief_cols=2
user_format=half type name | size | perm | mtime
user_status0=half type name | size | perm
user_status1=half type name | size | perm
user_status2=half type name | size | perm
user_status3=half type name | owner | group | ctime
user_mini_status=true
list_format=user
[Dirs]
current_is_left=true
other_dir=/home

2
psql/.config/psql/rc Normal file
View File

@ -0,0 +1,2 @@
\set HISTFILE ~/.psql_history-:DBNAME
\set HISTSIZE -1

View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
from pathlib import Path
import os
import atexit
import readline
history = os.getenv('PYTHON_HISTFILE')
if history:
try:
Path(history).parent.mkdir(parents=True, exist_ok=True)
readline.read_history_file(history)
except OSError:
pass
def write_history():
try:
readline.write_history_file(history)
except OSError:
pass
atexit.register(write_history)

View File

@ -0,0 +1,26 @@
#!/bin/sh
# Use neovim for vim if present.
[ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d"
# Verbosity and settings that you pretty much just always are going to want.
alias \
cp="cp -iv" \
mv="mv -iv" \
rm="rm -vI" \
mkd="mkdir -pv" \
# Colorize commands when possible.
alias \
ls="ls -hN --color=auto --group-directories-first" \
grep="grep --color=auto" \
diff="diff --color=auto" \
ccat="highlight --out-format=ansi"
# These common commands are just too long! Abbreviate them.
alias \
ka="killall" \
g="git" \
f="$FILE" \
e="$EDITOR" \
v="$EDITOR" \

View File

@ -0,0 +1,34 @@
#!/bin/sh
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
# Default editor
export EDITOR='vim'
# Shell history file
export HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/shell/history"
# Global git config file
export GIT_CONFIG_GLOBAL="${XDG_CONFIG_HOME:-$HOME/.config}/git/config"
# Make Python use UTF-8 encoding for output to stdin, stdout, and stderr.
export PYTHONIOENCODING='UTF-8'
# Python commands in that file are executed before the first prompt is displayed in interactive mode.
# The file is executed in the same namespace where interactive commands are executed
# so that objects defined or imported in it can be used without qualification in the interactive session.
export PYTHONSTARTUP="${XDG_CONFIG_HOME:-$HOME/.config}/python/startup"
# Custom Python history file
export PYTHON_HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/python/history"
# PostgreSQL config file
export PSQLRC="${XDG_CONFIG_HOME:-$HOME/.config}/psql/rc"
# Wget config file
export WGETRC="${XDG_CONFIG_HOME:-$HOME/.config}/wget/rc"
# ZSH directory
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"

View File

@ -0,0 +1 @@
#!/bin/sh

4
shell/.config/shell/path Normal file
View File

@ -0,0 +1,4 @@
#!/bin/sh
# Adds `~/.local/bin` to $PATH
export PATH="$PATH:${$(find ~/.local/bin -type d -printf %p:)%%:}"

View File

@ -0,0 +1,9 @@
#!/bin/sh
# Load the shell dotfiles, and then some:
# * ~/.path can be used to extend `$PATH`.
# * ~/.extra can be used for other settings you dont want to commit.
for file in ~/.config/shell/{path,exports,aliases,functions,extra}; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;

1
shell/.profile Symbolic link
View File

@ -0,0 +1 @@
.config/shell/profile

1
wget/.config/wget/rc Normal file
View File

@ -0,0 +1 @@
hsts-file=~/.cache/wget-hsts

71
zsh/.zshrc Normal file
View File

@ -0,0 +1,71 @@
# Luke's config for the Zoomer Shell
# Source (mainly): https://github.com/LukeSmithxyz/voidrice/
# Enable colors and change prompt:
autoload -U colors && colors # Load colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
setopt autocd # Automatically cd into typed directory.
stty stop undef # Disable ctrl-s to freeze terminal.
setopt interactive_comments
# History in cache directory:
HISTSIZE=10000000
SAVEHIST=10000000
# Basic auto/tab complete:
autoload -U compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # Include hidden files.
# vi mode
bindkey -v
export KEYTIMEOUT=1
# Use vim keys in tab complete menu:
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
# Change cursor shape for different vi modes.
function zle-keymap-select () {
case $KEYMAP in
vicmd) echo -ne '\e[1 q';; # block
viins|main) echo -ne '\e[5 q';; # beam
esac
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
echo -ne "\e[5 q"
}
zle -N zle-line-init
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
bindkey -s '^a' 'bc -lq\n'
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
bindkey '^[[P' delete-char
# Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line
bindkey '^e' edit-command-line
# Custom
# Activate history search based upon what has already been entered at the prompt,
# and always put cursor at the end of the line:
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end
# Load syntax highlighting; should be last.
source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null