This commit is contained in:
Jeffrey Serio 2022-09-13 08:37:45 -05:00
parent 465bdd2529
commit 757cce1bc4
16 changed files with 1063 additions and 285 deletions

143
.config/mc/ini Normal file
View File

@ -0,0 +1,143 @@
[Midnight-Commander]
verbose=true
shell_patterns=true
auto_save_setup=true
preallocate_space=false
auto_menu=false
use_internal_view=true
use_internal_edit=true
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=true
old_esc_mode=true
cd_symlinks=true
show_all_if_ambiguous=false
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
shadows=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=catppuccin
[Layout]
output_lines=0
left_panel_size=105
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=%b %e %H:%M
timeformat_old=%b %e %Y
ftp_proxy_host=gate
ftpfs_password=anonymous@
display_codepage=UTF-8
source_codepage=Other_8_bit
autodetect_codeset=
clipboard_store=
clipboard_paste=
[Colors]
base_color=
xterm-256color=
color_terminals=
[Panels]
show_mini_info=true
kilobyte_si=false
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=true
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
[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
Modified git files=git ls-files --modified

35
.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
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 | size | perm
user_mini_status=false
list_format=full
[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
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 | size | perm
user_mini_status=false
list_format=full
[Dirs]
current_is_left=true
other_dir=/var/home/jas

View File

@ -35,10 +35,12 @@ require('packer').startup(function()
use 'lukas-reineke/indent-blankline.nvim'
-- Add git related info in the signs columns and popups
use {
'lewis6991/gitsigns.nvim',
requires = { 'nvim-lua/plenary.nvim' }
}
-- use {
-- 'lewis6991/gitsigns.nvim',
-- config = function()
-- require('gitsigns').setup()
-- end
-- }
-- Highlight, edit, and navigate code using a fast incremental parsing library
use 'nvim-treesitter/nvim-treesitter'
@ -58,9 +60,6 @@ require('packer').startup(function()
-- Remember last edit location in file
use 'ethanholz/nvim-lastplace'
-- Colorize hex color codes
use 'norcalli/nvim-colorizer.lua'
-- File manager
use {
'kyazdani42/nvim-tree.lua',
@ -70,18 +69,12 @@ require('packer').startup(function()
config = function() require'nvim-tree'.setup{} end
}
-- dhall syntax
use 'vmchale/dhall-vim'
-- lualine
use {
'nvim-lualine/lualine.nvim',
requires = { 'kyazdan42/nvim-web-devicons', opt = true }
}
-- Embark color theme
-- use 'embark-theme/vim'
-- Editorconfig
use 'editorconfig/editorconfig-vim'
@ -91,24 +84,12 @@ require('packer').startup(function()
-- sloum/gemini-vim-syntax
use 'https://tildegit.org/sloum/gemini-vim-syntax'
-- dracula-pro/vim
-- use '~/.config/nvim/draculapro'
-- catppuccin theme
use {
'catppuccin/nvim',
as = 'catppuccin'
}
-- go.nvim
use 'ray-x/go.nvim'
-- fish syntax
use 'khaveesh/vim-fish-syntax'
-- Nim syntax
use 'alaviss/nim.nvim'
end)
-- Local map function
@ -161,11 +142,12 @@ vim.wo.signcolumn = 'yes'
--Set colorscheme (order is important here)
vim.o.termguicolors = true
vim.g.catppuccin_flavor = "mocha"
vim.cmd [[colorscheme catppuccin]]
vim.g.catppuccin_flavour = "mocha"
require("catppuccin").setup()
vim.cmd("colorscheme catppuccin")
--Highlight column 88
vim.cmd [[set colorcolumn=88]]
vim.cmd("set colorcolumn=88")
--Set splits
vim.o.splitbelow = true
@ -192,12 +174,12 @@ require('lualine').setup{
}
-- Sometimes I don't let go of the shift key in time
vim.cmd [[command! WQ wq]]
vim.cmd [[command! Wq wq]]
vim.cmd [[command! Wqa wqa]]
vim.cmd [[command! WQa wqa]]
vim.cmd [[command! W w]]
vim.cmd [[command! Q q]]
vim.cmd("command! WQ wq")
vim.cmd("command! Wq wq")
vim.cmd("command! Wqa wqa")
vim.cmd("command! WQa wqa")
vim.cmd("command! W w")
vim.cmd("command! Q q")
-- Sometimes I accidentally undo a change when trying to enter INSERT mode
map("n", "u", "<Nop>", opt)
@ -245,17 +227,6 @@ map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
map("n", "<TAB>", ":BufferLineCycleNext<CR>", opt)
map("n", "<S-TAB>", ":BufferLineCyclePrev<CR>", opt)
-- Gitsigns
require('gitsigns').setup {
signs = {
add = { hl = 'GitGutterAdd', text = '+' },
change = { hl = 'GitGutterChange', text = '~' },
delete = { hl = 'GitGutterDelete', text = '_' },
topdelete = { hl = 'GitGutterDelete', text = '' },
changedelete = { hl = 'GitGutterChange', text = '~' },
},
}
-- Telescope
require('telescope').setup {
defaults = {
@ -297,15 +268,6 @@ map('n', '<C-n>', ':NvimTreeToggle<CR>', opt)
map('n', '<leader>r', ':NvimTreeRefresh<CR>', opt)
map('n', '<leader>n', ':NvimTreeFindFile<CR>', opt)
-- go.nvim settings
vim.api.nvim_exec(
[[
autocmd BufWritePre *.go :silent! lua require('go.format').goimport()
]],
false
)
require('go').setup()
-- LSP settings
local nvim_lsp = require 'lspconfig'
local on_attach = function(_, bufnr)
@ -337,7 +299,7 @@ local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
-- Enable the following language servers
local servers = { 'bashls', 'dockerls', 'gopls', 'pyright', 'yamlls' }
local servers = { 'ansiblels', 'bashls', 'dockerls', 'jsonls', 'pyright', 'yamlls' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
@ -376,6 +338,7 @@ require('lspconfig').sumneko_lua.setup {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file('', true),
preloadFileSize = 1000,
checkThirdParty = false,
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
@ -385,6 +348,9 @@ require('lspconfig').sumneko_lua.setup {
},
}
-- Ansible LSP
require('lspconfig').ansiblels.setup{}
-- Bash LSP
require('lspconfig').bashls.setup{}
@ -394,9 +360,6 @@ require('lspconfig').dockerls.setup{}
-- JSON LSP
require('lspconfig').jsonls.setup{}
-- Nim LSP
require('lspconfig').nimls.setup{}
-- Pyright (Python) LSP
require('lspconfig').pyright.setup{}

View File

@ -0,0 +1,36 @@
# container-offlineimap.service
# autogenerated by Podman 4.1.1
# Tue Aug 16 12:45:40 CDT 2022
[Unit]
Description=Podman container-offlineimap.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--sdnotify=conmon \
-d \
--replace \
-it \
--name offlineimap \
--network host \
-v /var/home/jas/mail:/mail:Z \
-v /var/home/jas/.offlineimap-metadata:/metadata:Z \
-v /var/home/jas/.offlineimaprc:/.offlineimaprc:Z localhost/offlineimap
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=Run container-offlineimap.service daily at 22:00:00
[Timer]
OnCalendar=*-*-* 22:00:00
Persistent=true
[Install]
WantedBy=timers.target

View File

@ -1,3 +1,31 @@
# Filename: $HOME/.gitconfig
# Purpose: config for git(1)
# Author: Jeffrey Serio <hyperreal@fedoraproject.org>
# License: GPL v3
##############################################################################
[format]
numbered = auto
[color]
branch = yes
diff = auto
pager = yes
status = auto
[color "branch"]
current = green
local = yellow
remote = cyan
[color "diff"]
meta = yellow
frag = magenta
old = red
new = green
[color "status"]
header = magenta
added = green
changed = yellow
untracked = cyan
[commit]
[core]
editor = nvim
@ -10,3 +38,4 @@
name = Jeffrey Serio
[global]
# vim:ft=gitconfig ai et sw=4 ts=4:

139
.zshenv
View File

@ -1,48 +1,115 @@
# ~/.zshenv
## go paths
export GOPATH="${HOME}/go"
## path variable
# PATH variable declaration as array
# -U means unique, which tells the shell not to add anything to the array if it's
# already there.
typeset -U PATH path
path=(
/usr/local/bin
/usr/local/sbin
"${HOME}/.local/bin"
"${HOME}/bin"
"${GOPATH}/bin"
"${HOME}/.cargo/bin"
"${path[@]}"
)
# Add /usr/local dirs to PATH
path=("/usr/local/bin" "/usr/local/sbin")
path+=("/bin" "/sbin" "/usr/bin" "/usr/sbin")
# Add nimble (Nim) to PATH
[ -d "${HOME}/.nimble/bin" ] && path+=("${HOME}/.nimble/bin")
# Set Go path if it exist
[ -d "${HOME}/go" ] && GOPATH="${HOME}/go" && path+=("${GOPATH}/bin")
# Set Cargo path for Rust binaries
[ -d "${HOME}/.cargo/bin" ] && path+=("${HOME}/.cargo/bin")
# If ~/bin exists, add it to PATH
[ -d "${HOME}/bin" ] && path+=("${HOME}/bin")
# If ~/.local/bin exists, add it to path
[ -d "${HOME}/.local/bin" ] && path+=("${HOME}/.local/bin")
export PATH
## reply-to email address
# Setup pager
if [[ -x $(which most) ]]; then
export PAGER="most"
export MANPAGER="most"
else
export PAGER="less -X"
export MANPAGER="less -iMXF"
if [[ $terminfo[colors] -ge 8 ]]; then
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
fi
fi
# Editor - Neovim, else nano
if test -x "$(command -v nvim)"; then
EDITOR=nvim
elif test -x "$(command -v vim)"; then
EDITOR=vim
else
EDITOR=nano
fi
export EDITOR
# lscolors (generated from vivid)
if [ -f ~/.lscolors.sh ]; then
export LS_COLORS=$(cat ~/.lscolors.sh)
fi
# Format of process time reports with 'time'
# %% A '%'
# %U CPU seconds spent in user mode
# %S CPU seconds spent in kernel mode
# %E Elapsed time in seconds
# %P CPU percentage, computed as (%U+%S)/%E
# %J The name of this job
# Default is:
# %E real %U user %S system %P %J
TIMEFMT="\
The name of this job : %J
CPU seconds spent in user mode : %U
CPU seconds spent in kernel mode : %S
Elapsed time in seconds : %E
CPU percentage : %P"
# HISTSIZE is the number of lines of history that is kept within any given
# running zsh instance. SAVEHIST is the number of lines of history that is
# written out to the HISTFILE when that event occurs. If you use the
# HIST_EXPIRE_DUPS_FIRST option, setting this value larger than the SAVEHIST
# size will give you the difference as a cushion for saving duplicated history
# events.
HISTSIZE=100000
SAVEHIST=65536
# Name of the file used to store command history
HISTFILE=~/.zsh_history
# If nonnegative, commands whose combined user and system execution times
# (measured in seconds) are greater than this value have timing stats printed
# for them.
REPORTTIME=10
# reply-to email address
export REPLYTO="hyperreal@fedoraproject.org"
## set language
export LANG=en_US.UTF-8
# Language
export LANG="en_US.UTF-8"
## set default editor
export EDITOR="nvim"
# Manpages
export MANPATH="${MANPATH:-/usr/share/man:/usr/local/share/man}"
## manpages
export MANPATH="${MANPATH:-/usr/share/man:/usr/local/share/man:/var/home/jas/.fzf/man}"
if [ -d "${HOME}/.fzf/man" ]; then
export MANPATH="${MANPATH}:${HOME}/.fzf/man"
fi
## manpage colors
export LESS_TERMCAP_mb=$'\e[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\e[01;37m' # begin bold
export LESS_TERMCAP_me=$'\e[0m' # end all mode like so, us, mb, md, mr
export LESS_TERMCAP_se=$'\e[0m' # end standout-mode
export LESS_TERMCAP_so=$'\e[45;93m' # start standout mode
export LESS_TERMCAP_ue=$'\e[0m' # end underline
export LESS_TERMCAP_us=$'\e[4;93m' # start underlining
## set pager stuffs
# Bat theme
export BAT_THEME="Catppuccin"
## set history stuffs
export HISTFILE=~/.zsh_history
export HISTSIZE=10000
export SAVEHIST=10000
# Automatically remove duplicates from these arrays
typeset -gU path cdpath manpath fpath
# vim:set ft=zsh ai et sw=4 ts=4:

86
.zshrc
View File

@ -1,6 +1,46 @@
# ~/.zshrc
# Filename : ~/.zshrc
# Purpose : setup file for zsh
# Author : Jeffrey Serio <hyperreal@fedoraproject.org>
# Homepage : https://hyperreal.coffee
#
# Zsh Manual - https://zsh-manual.netlify.app
# Zsh Guide - https://zsh-guide.netlify.app
#
# ,----[ man -k zsh ]
# |
# | zsh (1) - the Z shell
# | zshall (1) - the Z shell meta-man page
# | zshbuiltins (1) - zsh builtin commands
# | zshcalsys (1) - zsh calendar system
# | zshcompctl (1) - zsh programmable completion
# | zshcompsys (1) - zsh completion system
# | zshcompwid (1) - zsh completion widgets
# | zshcontrib (1) - user contributions to zsh
# | zshexpn (1) - zsh expansion and substitution
# | zshmisc (1) - everything and then some
# | zshmodules (1) - zsh loadable modules
# | zshoptions (1) - zsh options
# | zshparam (1) - zsh parameters
# | zshroadmap (1) - informal introduction to the zsh manual
# | zshtcpsys (1) - zsh tcp system
# | zshzftpsys (1) - zftp function front-end
# | zshzle (1) - zsh command line editor
# `----
#
# Zsh startup sequence
# 1) /etc/zshenv -> Always run for every zsh. (login + interactive + other)
# 2) ~/.zshenv -> Usually run for every zsh. (login + interactive + other)
# 3) /etc/zprofile -> Run for login shells. (login)
# 4) ~/.zprofile -> Run for login shells. (login)
# 5) /etc/zshrc -> Run for interactive shells. (login + interactive)
# 6) ~/.zshrc -> Run for interactive shells. (login + interactive)
# 7) /etc/zlogin -> Run for login shells. (login)
# 8) ~/.zlogin -> Run for login shells. (login)
#
# This file is based on Christian Schneider's zsh configuration
# https://www.strcat.de/dotfiles
## Plugins
# Plugins
if ! test -f ~/.zplug/init.zsh; then
export ZPLUG_HOME=~/.zplug
git clone https://github.com/zplug/zplug $ZPLUG_HOME
@ -8,18 +48,25 @@ fi
source ~/.zplug/init.zsh
zplug "~/.zshrc.d", from:local, use:'(*).zsh'
# Load file from ~/.zshrc.d
zplug "~/.zshrc.d", from:local, use:'*'
# Use autosuggestions when typing commands
zplug "zsh-users/zsh-autosuggestions"
# Use a keybinding to complete parts of command from the history file
zplug "zsh-users/zsh-history-substring-search"
# Use syntax highlighting when typing commands
zplug "zsh-users/zsh-syntax-highlighting", defer:2
zplug "amaya382/zsh-fzf-widgets"
zplug "chitoku-k/fzf-zsh-completions"
zplug "plugins/dnf", from:oh-my-zsh
zplug "plugins/extract", from:oh-my-zsh
zplug "plugins/firewalld", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh
# Press escape twice to prepend `sudo` to the command line
zplug "plugins/sudo", from:oh-my-zsh
# systemd aliases
zplug "plugins/systemd", from:oh-my-zsh
# Directory bookmarks using FZF
zplug "urbainvaes/fzf-marks"
if ! zplug check; then
@ -29,27 +76,10 @@ fi
zplug load
## General shell options
# See https://zsh-manual.netlify.app/options
setopt appendhistory
setopt autocd
setopt autolist
setopt automenu
setopt autoremoveslash
setopt cdablevars
setopt histallowclobber
setopt histignorealldups
setopt histignoredups
setopt histsavenodups
setopt interactivecomments
setopt listpacked
setopt listtypes
setopt longlistjobs
## lscolors
# lscolors.sh
export LS_COLORS=$(cat ~/.lscolors.sh)
## Prompt
# starship.rs prompt
eval "$(starship init zsh)"
# vim:set ft=zsh ai et sw=4 ts=4:

View File

@ -1,71 +0,0 @@
# ~/.zshrc.d/aliases.zsh
## the ls family
if test -x "$(command -v exa)"; then
alias ls="exa"
fi
alias l="ls -lFhg"
alias la="ls -a"
alias ll="ls -l"
alias lal="ls -al"
alias ldot="ls -gld .*"
alias lse="/bin/ls -lZ"
lgn() { exa --tree --level=$1 ; }
## greps
alias grep="grep --color"
alias sgrep="grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}"
## copy SSH pubkey to clipboard
alias pubkey="more ~/.ssh/id_ed25519.pub | xclip -selection clipboard | echo '==> SSH public key copied'"
## mosh
alias mosh="mosh -p 60001"
## display disk usage with dust
alias dud="dust --depth 1 -w 88"
## prompt user before overwriting copied and moved files
alias cp="cp -i"
alias mv="mv -i"
alias rm="rm -i"
## display zsh functions with bat
alias zfun="functions | bat -l zsh"
## luamake
alias luamake="/home/jas/.local/share/sumneko/lua-language-server/3rd/luamake/luamake"
## assorted globals
alias -g H="| head"
alias -g T="| tail"
alias -g G="| grep"
alias -g L="| less -X"
alias -g B="| bat"
alias -g LL="2>&1 | less"
alias -g CA="2>&1 | cat -A"
alias -g NE="2> /dev/null"
alias -g NUL="> /dev/null 2>&1"
alias -g P="2>&1| pygmentize -l pytb"
alias -g J="| jq ."
alias -g CC="| xclip -selection clipboard"
## networking
alias pubip="curl ipinfo.io"
alias netCons="lsof -i"
alias tulp="ss -tulp"
alias openPorts="sudo lsof -i | grep LISTEN"
alias pong="ping -c 3 www.google.com"
alias lsock="sudo lsof -i -P"
alias lsockU="sudo lsof -nP | grep UDP"
alias lsockT="sudo lsof -nP | grep TCP"
## logs directory
alias logs="ls /var/log/"
## reboot/poweroff
alias rbt="sudo systemctl reboot"
alias shut="sudo systemctl poweroff"
# vim:set ft=zsh ai et sw=4 ts=4:

View File

@ -15,21 +15,21 @@ ZSH_HIGHLIGHT_STYLES[comment]='fg=#585b70'
## Constants
## Entitites
## Functions/methods
ZSH_HIGHLIGHT_STYLES[alias]='fg=#cba6f7'
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=#cba6f7'
ZSH_HIGHLIGHT_STYLES[global-alias]='fg=#cba6f7'
ZSH_HIGHLIGHT_STYLES[function]='fg=#cba6f7'
ZSH_HIGHLIGHT_STYLES[command]='fg=#cba6f7'
ZSH_HIGHLIGHT_STYLES[precommand]='fg=#cba6f7,italic'
ZSH_HIGHLIGHT_STYLES[alias]='fg=#a6e3a1'
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=#a6e3a1'
ZSH_HIGHLIGHT_STYLES[global-alias]='fg=#a6e3a1'
ZSH_HIGHLIGHT_STYLES[function]='fg=#a6e3a1'
ZSH_HIGHLIGHT_STYLES[command]='fg=#a6e3a1'
ZSH_HIGHLIGHT_STYLES[precommand]='fg=#a6e3a1,italic'
ZSH_HIGHLIGHT_STYLES[autodirectory]='fg=#fab387,italic'
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=#fab387'
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=#fab387'
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='fg=#cba6f7'
## Keywords
## Built ins
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#94e2d5'
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=#94e2d5'
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=#94e2d5'
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#a6e3a1'
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=#a6e3a1'
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=#a6e3a1'
## Punctuation
ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=#f38ba8'
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]='fg=#cdd6f4'
@ -57,10 +57,10 @@ ZSH_HIGHLIGHT_STYLES[named-fd]='fg=#cdd6f4'
ZSH_HIGHLIGHT_STYLES[numeric-fd]='fg=#cdd6f4'
## No category relevant in spec
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=#e64553'
ZSH_HIGHLIGHT_STYLES[path]='fg=#cdd6f4'
ZSH_HIGHLIGHT_STYLES[path_pathseparator]='fg=#f38ba8'
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=#cdd6f4'
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]='fg=#f38ba8'
ZSH_HIGHLIGHT_STYLES[path]='fg=#cdd6f4,underline'
ZSH_HIGHLIGHT_STYLES[path_pathseparator]='fg=#f38ba8,underline'
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=#cdd6f4,underline'
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]='fg=#f38ba8,underline'
ZSH_HIGHLIGHT_STYLES[globbing]='fg=#cdd6f4'
ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=#cba6f7'
#ZSH_HIGHLIGHT_STYLES[command-substitution]='fg=?'

View File

@ -1,77 +0,0 @@
# ~/.zshrc.d/functions.zsh
## Do an ls after cd
cd() { builtin cd "$@" && ls; }
## Create new directory and enter it
mkd() { mkdir -p "$@" && cd "$_"; }
## pids
pids() { pgrep -a "$@"; }
## variation of our manzsh() function; pick you poison:
manzsh() { /usr/bin/man zshall | most +/"$1" ; }
## restart zsh
restart () {
exec $SHELL $SHELL_ARGS "$@"
}
rsrc() { cd && clear && restart; }
## parse HackerNews feed (https://hnrss.org/newest)
hn() {
python3 <(cat <<EOF
import feedparser
HNFeed = feedparser.parse("https://hnrss.org/newest")
class bcolors:
HEADER = '\033[95m'
ENDC = '\033[0m'
for item in HNFeed.entries:
print(f"{bcolors.HEADER}%s{bcolors.ENDC}" % item.title)
print(item.links[0].href)
print("")
EOF
) | bat -p
}
## fetch open source license
license() {
local base_url
base_url="https://api.github.com/licenses"
local headers
headers="Accept: application/vnd.github.drax-preview+json"
local res
if (( $# == 0 )); then
res=$(curl --silent --header $headers $base_url)
echo "Available licenses:"
echo
echo "$res" | jq ".[].key" | tr -d '"'
fi
local license="$argv[1]"
res=$(curl --silent --header $headers $base_url/$license | jq ."body")
echo -e $res | tr -d '"'
}
nmap_ssh() {
if sudo podman image exists localhost/nmap; then
sudo podman run -it --rm \
--cap-add=NET_RAW \
--cap-add=NET_ADMIN \
--network host \
--name nmap \
nmap -sV -p 22 -open 10.0.0.0/24
else
echo "localhost/nmap image does not exist"
fi
}
# vim:set ft=zsh ai et sw=4 ts=4:

148
.zshrc.d/zshaliases Normal file
View File

@ -0,0 +1,148 @@
# Get top 10 shell commands
alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
# history mechanism
alias h='history'
# Aliases for APT
if [ -e "/etc/debian_version" ]; then
alias acs="sudo apt-cache search"
alias acp="sudo apt-cache policy"
alias afs="sudo apt-file search"
alias afu="sudo apt-file update"
alias aac="sudo apt autoclean"
alias agc="sudo apt clean"
alias agi="sudo apt install"
alias agli="sudo apt list --installed"
alias agp="sudo apt purge"
alias agr="sudo apt remove"
alias agu="sudo apt update"
alias agud="sudo apt update && sudo apt dist-upgrade"
alias agar="sudo apt autoremove"
fi
if [ -e "/etc/redhat-release" ]; then
alias dnfc='sudo dnf clean all'
alias dnfgi='sudo dnf groupinstall'
alias dnfgl='dnf grouplist'
alias dnfgr='sudo dnf groupremove'
alias dnfi='sudo dnf install'
alias dnfl='dnf list'
alias dnfli='dnf list installed'
alias dnfmc='dnf makecache'
alias dnfp='dnf info'
alias dnfr='sudo dnf remove'
alias dnfs='dnf search'
alias dnfu='sudo dnf update'
fi
# Convert UPPER to lower (or back)
alias UP2low='for i in *(.); mv $i ${i:l}'
alias low2UP='for i in *(.); mv $i ${i:u}'
# The ls family
if test -x "$(command -v exa)"; then
alias ls='exa'
else
alias ls='ls --color=auto'
fi
alias l='ls -lFhg'
alias la='ls -a'
alias ll='ls -l'
alias lal='ls -al'
alias ldot='ls -gld .*'
alias lse='/bin/ls -lZ'
# greps
alias grep='grep --color'
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}'
# Copy SSH public key to clipboard (requires xclip or xsel)
if test -x "$(command -v xclip)"; then
alias pubkey='more ~/.ssh/id_ed25519.pub | xclip -selection clipboard | echo "SSH public key copied"'
fi
# Prompt user before overwriting files
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
# Display zsh functions with bat
alias zfun='functions | bat -l zsh'
# Assorted global aliases
alias -g H='| head'
alias -g T='| tail'
alias -g G='| grep'
alias -g L='| less -X'
alias -g B='| bat'
alias -g LL='2>&1 | less'
alias -g NE='2> /dev/null'
alias -g NUL='> /dev/null 2>&1'
alias -g P='2>&1| pygmentize -l pytb'
alias -g J='| jq'
alias -g CC='| xclip -selection clipboard'
alias -g C='| wc -l'
alias -g SS='| sort'
alias -g Su='| sort -u'
alias -g Sn='| sort -n'
alias -g Snr='| sort -nr'
# Get public IP address
alias pubip='curl ipinfo.io'
# List apps with network connections
alias netCons='lsof -i'
# List ports
alias tulp='ss -tulp'
# List open ports
alias openPorts='sudo lsof -i | grep LISTEN'
# Ping google.com
alias pong='ping -c 3 www.google.com'
# List sockets in use
alias lsock='sudo lsof -i -P'
# List UDP sockets in use
alias lsockU='sudo lsof -nP | grep UDP'
# List TCP sockets in use
alias lsockT='sudo lsof -nP | grep TCP'
# Reboot / Poweroff
alias rbt='sudo systemctl reboot'
alias shut='sudo systemctl poweroff'
# GPG
alias gpgs='gpg --search-keys'
alias gpgl='gpg --list-keys --with-fingerprint'
# Suffix aliases
alias -s {conf,config,cfg,md,rc,txt,zshrc}="nvim"
# firewalld
if test -x "$(command -v firewall-cmd)"; then
alias fw='sudo firewall-cmd'
alias fwp='sudo firewall-cmd --permanent'
alias fwr='sudo firewall-cmd --reload'
alias fwrp='sudo firewall-cmd --runtime-to-permanent'
fi
# git
alias ga='git add'
alias gcl='git clone'
alias gcmsg='git commit -m'
alias gd='git diff'
alias gl='git pull'
alias gp='git push'
alias gr='git remote'
alias grbi='git rebase -i'
alias grm='git rm'
alias grv='git remote -v'
alias gst='git status'
# vim:set ft=zsh ai et sw=4 ts=4:

View File

@ -1,5 +1,3 @@
# ~/.zshrc.d/input.zsh
typeset -g -A key
key[Home]="${terminfo[khome]}"

314
.zshrc.d/zshfunctions Normal file
View File

@ -0,0 +1,314 @@
# snakify filenames
snakify () {
emulate -L zsh
local filename=$(basename -- "$1")
local extension="${filename##*.}"
local filename="${filename%.*}"
local new_filename=$(echo ${filename// /_} | tr '-' '_' | tr -cd '[:alnum:]._-')
local new_basename=$(echo "$new_filename.$extension")
mv -i "$1" "$new_basename"
mv -i "$new_basename" "${new_basename:l}"
}
# Print timestamp
tstamp() {
emulate -L zsh
date '+%Y-%m-%d %H:%M:%S'
}
# Find history events by search pattern and list them by date.
whatwhen () {
emulate -L zsh
local usage help ident format_l format_s first_char remain first last
usage='USAGE: whatwhen [options] <searchstring> <search range>'
help='Use `whatwhen -h'\'' for further explanations.'
ident=${(l,${#${:-Usage: }},, ,)}
format_l="${ident}%s\t\t\t%s\n"
format_s="${format_l//(\\t)##/\\t}"
# Make the first char of the word to search for case
# insensitive; e.g. [aA]
first_char=[${(L)1[1]}${(U)1[1]}]
remain=${1[2,-1]}
# Default search range is `-100'.
first=${2:-\-100}
# Optional, just used for `<first> <last>' given.
last=$3
case $1 in
("")
printf '%s\n\n' 'ERROR: No search string specified. Aborting.'
printf '%s\n%s\n\n' ${usage} ${help} && return 1
;;
(-h)
printf '%s\n\n' ${usage}
print 'OPTIONS:'
printf $format_l '-h' 'show help text'
print '\f'
print 'SEARCH RANGE:'
printf $format_l "'0'" 'the whole history,'
printf $format_l '-<n>' 'offset to the current history number; (default: -100)'
printf $format_s '<[-]first> [<last>]' 'just searching within a give range'
printf '\n%s\n' 'EXAMPLES:'
printf ${format_l/(\\t)/} 'whatwhen grml' '# Range is set to -100 by default.'
printf $format_l 'whatwhen zsh -250'
printf $format_l 'whatwhen foo 1 99'
;;
(\?)
printf '%s\n%s\n\n' ${usage} ${help} && return 1
;;
(*)
# -l list results on stout rather than invoking $EDITOR.
# -i Print dates as in YYYY-MM-DD.
# -m Search for a - quoted - pattern within the history.
fc -li -m "*${first_char}${remain}*" $first $last
;;
esac
}
alias x=extract
extract() {
setopt localoptions noautopushd
if (( $# == 0 )); then
cat >&2 <<'EOF'
Usage: extract [-option] [file ...]
Options:
-r, --remove Remove archive after unpacking.
EOF
fi
local remove_archive=1
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
remove_archive=0
shift
fi
local pwd="$PWD"
while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then
echo "extract: '$1' is not a valid file" >&2
shift
continue
fi
local success=0
local extract_dir="${1:t:r}"
local file="$1" full_path="${1:A}"
case "${file:l}" in
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$file" | tar xv } || tar zxvf "$file" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$file" ;;
(*.tar.xz|*.txz)
tar --xz --help &> /dev/null \
&& tar --xz -xvf "$file" \
|| xzcat "$file" | tar xvf - ;;
(*.tar.zma|*.tlz)
tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$file" \
|| lzcat "$file" | tar xvf - ;;
(*.tar.zst|*.tzst)
tar --zstd --help &> /dev/null \
&& tar --zstd -xvf "$file" \
|| zstdcat "$file" | tar xvf - ;;
(*.tar) tar xvf "$file" ;;
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$file" ;;
(*.tar.lz4) lz4 -c -d "$file" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$file" ;;
(*.gz) (( $+commands[pigz] )) && pigz -dk "$file" || gunzip -k "$file" ;;
(*.bz2) bunzip2 "$file" ;;
(*.xz) unxz "$file" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$file" ;;
(*.lz4) lz4 -d "$file" ;;
(*.lzma) unlzma "$file" ;;
(*.z) uncompress "$file" ;;
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$file" -d "$extract_dir" ;;
(*.rar) unrar x -ad "$file" ;;
(*.rpm)
command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \
&& rpm2cpio "$full_path" | cpio --quiet -id ;;
(*.7z) 7za x "$file" ;;
(*.deb)
command mkdir -p "$extract_dir/control" "$extract_dir/data"
builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null
builtin cd -q control; extract ../control.tar.*
builtin cd -q ../data; extract ../data.tar.*
builtin cd -q ..; command rm *.tar.* debian-binary ;;
(*.zst) unzstd "$file" ;;
(*.cab) cabextract -d "$extract_dir" "$file" ;;
(*.cpio) cpio -idmvF "$file" ;;
(*)
echo "extract: '$file' cannot be extracted" >&2
success=1 ;;
esac
(( success = success > 0 ? success : $? ))
(( success == 0 && remove_archive == 0 )) && rm "$full_path"
shift
# Go back to original working directory in case we ran cd previously
builtin cd -q "$pwd"
done
}
# ARCHIVE: Create a tarball from given directory
function create-archive()
{
local archive_name
archive_name="$1.tar.gz"
archive_name=${archive_name/\//}
tar cvfz "$archive_name" "$1"
echo "Created archive $archive_name"
}
compdef _directories create-archive
# Create a /overview/ of all available function()'s; the description for
# each funtion() *must* be the first line above the string `function'!
# Otherwise it wont work.
# Display all function()'s with her descriptions
function funlist()
{
grep -B 1 "^function" $HOME/.zshrc.d/zshfunctions | \
grep -v "^\-\-$" | \
awk '{ if(/^#/) { gsub(/^#[:space:]*/, ""); ht=$0 }; getline; gsub(/ ?\(\)/, ":"); printf("-> %-20s %s\n", $2, ht); }' | \
sort -u -k 3
}
# show directory stack and ask for a dir to switch to
function dstack() {
emulate -L zsh
autoload -U colors
local color=$fg_bold[blue]
integer i=0
dirs -p | while read dir
do
local num="${$(printf "%-4d " $i)/ /.}"
printf " %s $color%s$reset_color\n" $num $dir
(( i++ ))
done
integer dir=-1
read -r 'dir?Jump to directory: ' || return
(( dir == -1 )) && return
if (( dir < 0 || dir >= i ))
then
echo d: no such directory stack entry: $dir
return 1
fi
cd ~$dir
}
# zremovecomp() remove *.zwc files
function zremovecomp() {
local i
for i in ${HOME}/*.zwc(N); do
printf "Removing $i\n"
command rm -f $i
done
}
# grep(1)'ing $HISTFILE
histgrep () { fc -fl -m "*(#i)$1*" 1 | grep -i --color $1 }
# A nicer output of cal(1)
# MISC: Colorize the output of cal(1)
function calendar() {
if [[ ! -f /usr/bin/cal ]] ; then
echo "Please install cal before trying to use it!"
return
fi
if [[ "$#" = "0" ]] ; then
/usr/bin/cal | egrep -C 40 --color "\<$(date +%e| tr -d ' ')\>"
else
/usr/bin/cal $@ | egrep -C 40 --color "\<($(date +%B)|$(date +%e | tr -d ' '))\>"
fi
}
# PROG: invoke this every time when u change .zshrc to recompile it.
function src()
{
autoload -U zrecompile
[ -f ~/.zshrc ] && zrecompile -p ~/.zshrc
[ -f ~/.zcompdump ] && zrecompile -p ~/.zcompdump
[ -f ~/.zcompdump ] && zrecompile -p ~/.zcompdump
[ -f ~/.zshrc.zwc.old ] && command rm -f ~/.zshrc.zwc.old
[ -f ~/.zcompdump.zwc.old ] && command rm -f ~/.zcompdump.zwc.old
source ~/.zshrc
}
# Do an ls after cd
cd() { builtin cd "$@" && ls; }
# Create new directory and enter it
mkd() { mkdir -p "$@" && cd "$_"; }
# pids
pids() { pgrep -a "$@"; }
# zshall manpage
manzsh() { /usr/bin/man zshall | most +/"$1" ; }
# Restart zsh
restart() {
exec $SHELL $SHELL_ARGS "$@"
}
rsrc() { cd && clear && restart; }
# Parse HackerNews feed (https://hnrss.org/newest)
hn() {
python3 <(cat <<EOF
import feedparser
HNFeed = feedparser.parse("https://hnrss.org/newest")
class bcolors:
HEADER = '\033[95m'
ENDC = '\033[0m'
for item in HNFeed.entries:
print(f"{bcolors.HEADER}%s{bcolors.ENDC}" % item.title)
print(item.links[0].href)
print("")
EOF
) | bat -p
}
# fetch open source license
license() {
local base_url
base_url="https://api.github.com/licenses"
local headers
headers="Accept: application/vnd.github.drax-preview+json"
local res
if (( $# == 0 )); then
res=$(curl --silent --header $headers $base_url)
echo "Available licenses:"
echo
echo "$res" | jq ".[].key" | tr -d '"'
fi
local license="$argv[1]"
res=$(curl --silent --header $headers $base_url/$license | jq ."body")
echo -e $res | tr -d '"'
}
# use nmap from podman to check for open SSH ports on local net
if test -x "$(command -v podman)"; then
nmap_ssh() {
if sudo podman image exists localhost/nmap; then
sudo podman run -it --rm \
--cap-add=NET_RAW \
--cap-add=NET_ADMIN \
--network host \
--name nmap \
nmap -sV -p 22 -open 10.0.0.0/24
else
echo "localhost/nmap image does not exist"
fi
}
fi
# vim:set ft=zsh ai et sw=4 ts=4:

154
.zshrc.d/zshoptions Normal file
View File

@ -0,0 +1,154 @@
## General shell options
# See https://zsh-manual.netlify.app/options
# This is a multiple move based on zsh pattern matching (like "mmv").
# Read ``less ${^fpath}/zmv(N)'' for more details.
autoload zmv
# A builtin that can clone a running shell onto another terminal.
zmodload -e zsh/clone
# When listing options (by 'setopt', 'unsetopt', 'set -o', or 'set +o'),
# those turned on by default appear in the list prefixed with 'no'.
# Hence (unless KSH_OPTION_PRINT is set), 'setopt' shows all options whose
# settings are changed from default.
#
# Report the status of background jobs immediately, rather than waiting until
# just before printing a prompt.
setopt notify
# Allow comments even in interactive shells.
setopt interactivecomments
# Send *not* a HUP signal to running jobs when the shell exits.
setopt nohup
# If a pattern for filename generation has no matches, delete the pattern from
# the argument list instead of reporting an error.
# Overrides NOMATCH
setopt nullglob
# Perform =filename access
# $ setopt EQUALS
# $ echo =ls
# /bin/ls
# $ unsetopt EQUALS
# $ echo =ls
# =ls
# NOTE: It's not really needed because zsh sets the per default.
setopt equals
# Try to make completion list smaller by printing the matches in columns with
# different widths.
setopt list_packed
# Expands single letters and ranges of letters between braces
# $ print 1{abw-z}2
# $ 1a2 1b2 1w2 1y2 1z2
setopt braceccl
# If the argument to a cd command (or an implied cd with the AUTO_CD option
# set) is not a directory, and does not begin with a slash, try to expand the
# expression as if it were preceded by a '~' (See section 14.7 Filename
# Expansion).
setopt cdablevars
# Report the status of background and suspended jobs before exiting a shell
# with job control; a second attempt to exit the shell will succeed.
setopt checkjobs
# Make cd push the old directory onto the directory stack.
setopt autopushd
# Change to directory without cd
setopt autocd
# Query the user before executing 'rm *' or 'rm path/*'
setopt normstarsilent
setopt no_rm_star_wait
# Shaddapa you face
setopt nobeep
# When writing out the history file, older commands that duplicate newer ones
# are omitted.
set histsavenodups
# When searching for history entries in the line editor, do not display
# duplicates of a line previously found, even if the duplicates are not
# contiguous.
setopt histfindnodups
# If the internal history needs to be trimmed to add the current command line,
# setting this option will cause the oldest history event that has a duplicate
# to be lost before losing a unique event from the list.
setopt hist_expire_dups_first
# If a new command line being added to the history list duplicates an older
# one, the older command is removed from the list (even if it is not the
# previous event).
setopt hist_ignore_all_dups
# Do not enter command lines into the history list if they are duplicates of
# the previous event.
setopt hist_ignore_dups
# Remove superfluous blanks from each command line being added to history.
setopt hist_reduce_blanks
# Whenever the user enters a line with history expansion, don't execute the
# line directly; instead, perform history expansion and reload the line into
# the editing buffer.
setopt hist_verify
# Do not remove function definitions from the history list.
unsetopt hist_no_functions
# Remove the history (fc -l) command from the history list when invoked.
# Note that the command lingers in the internal history until the next command
# is entered before it vanishes, allowing you to briefly reuse or edit the
# line.
setopt hist_no_store
# If this is set, zsh sessions will append their history list to the history
# file, rather than overwrite it. Thus, multiple parallel zsh sessions will all
# have their history lists added to the history file, in the order they are
# killed.
setopt appendhistory
# If unset, the cursor is set to the end of the word if completion is started.
# Otherwise, it stays there and completion is done from both ends.
unsetopt completeinword
# When listing files that are possible completions, show the type of each file
# with a trailing identifying mark.
setopt listtypes
# Do not require a leading '.' in a filename to be matched explicitly.
setopt globdots
# List jobs in long format by default
setopt longlistjobs
# Don't push multiple copies of the same directory onto the directory staack.
setopt pushdignoredups
# This option both imports new commands from the history file, and also causes
# your typed commands to be appended to the history file (the latter is like
# specifying INC_APPEND_HISTORY).
# The history lines are also output with timestamps ala EXTENDED_HISTORY
# (which makes it easier to find the spot where we left off reading the file
# after it gets re-written).
setopt sharehistory
# Save each command's beginning timestamp (in seconds since the epoch)
# and the duration (in seconds) to the history file. The format of this
# prefixed data is:
# ':<beginning time>:<elapsed seconds>;<command>'
setopt extendedhistory
# Do *not* run all background jobs at a lower nice priority
unsetopt bgnice
# vim:set ft=zsh ai et sw=4 ts=4: