Compare commits

...

9 Commits

Author SHA1 Message Date
Michel ff2cae46be Merge branch 'main' into opt 2024-01-23 10:43:46 +01:00
Michel 5312fd7bf2 feat: mount devices once connected 2024-01-22 16:54:59 +01:00
Michel e0b9335f2b feat: use .xprofile
feat: use .xprofile
2024-01-22 16:45:51 +01:00
Michel 9be893d07f feat(zsh): whiptail helpers 2024-01-22 16:41:50 +01:00
Michel d45e45e011 feat(n³): file selector 2024-01-22 10:15:07 +01:00
Michel 0756bd5272 feat(zsh): whiptail helper 2024-01-17 16:32:04 +01:00
Michel 7df92af4f1 fix(lsd): update to 1.0 2024-01-15 15:41:09 +01:00
Michel a1ef675695 doc: zshrc 2024-01-15 15:25:44 +01:00
Michel 010ee78078 feat(zsh): n³ & undo 2024-01-12 10:55:31 +01:00
6 changed files with 120 additions and 13 deletions

View File

@ -11,7 +11,7 @@ blocks:
color:
when: auto
theme: michel
theme: custom
# Possible values: date, relative, '+<date_format>'
# `date_format` will be a `strftime` formatted value.

2
.xprofile Normal file
View File

@ -0,0 +1,2 @@
export NC_STORAGE="$HOME/NC-Michel/Linux/folder"
export ALT_HISTORY_FILE="$HOME/NC-Michel/Linux/another-folder/history"

View File

@ -1,2 +0,0 @@
export NC_STORAGE="$HOME/NC-Michel/Linux/VDell"
export ALT_HISTORY_FILE="$HOME/NC-Michel/Linux/michdell/history"

119
.zshrc
View File

@ -118,7 +118,7 @@ if [[ -f $ALT_HISTORY_FILE ]]; then
bindkey -M viins '^[[114;13u' fzf-alt-history-widget
fi
### ZVM
### ZVM — Zsh VI mode
#
# https://github.com/jeffreytse/zsh-vi-mode
@ -229,13 +229,13 @@ compdef hg=rg
# nnn - n³
#
# See https://github.com/jarun/nnn/wiki/Usage#configuration
export NNN_ARCHIVE='\.(7z|bz2|gz|tar|tbz|tgz|xz|zip|zst)$'
export NNN_ARCHIVE='\.(7z|bz2|cbz|cbr|gz|tar|tbz|tgz|xz|zip|zst)$'
if (( ${+commands[fuse-archive]} )); then
export NNN_ARCHMNT='fuse-archive'
fi
export NNN_BMS="d:~/Downloads;q:~/QubesIncoming"
export NNN_OPENER="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke"
export NNN_OPTS='ABeGHo'
export NNN_OPTS='ABeGo'
export NNN_ORDER="t:$HOME/Downloads"
export NNN_PLUG='d:fzcd;o:-!xdg-open "$nnn"*;z:fzopen'
if (( ${+commands[trash-put]} )); then
@ -257,23 +257,121 @@ n()
command nnn "$@"
if [ -f $NNN_TMPFILE ]; then
setopt autopushd
# Tmp file contains a `cd` directive that will
# behave like a `pushd`, ignoring duplicates.
setopt autopushd pushdignoredups
. $NNN_TMPFILE
rm -f $NNN_TMPFILE > /dev/null
dirs -v
fi
}
nnn-file-widget() {
local item
nnn -p- <"$TTY" |
while read item; do
LBUFFER+="${(q-)item} "
done
# Extract "shell word" at cursor position (respecting quotes)
local _cursor=$CURSOR
zle .select-a-shell-word -N
# Helper
nnn-pick()
{
IFS=$'\n'
local items=( $(command nnn -p- $1 < "$TTY") )
if (( #items > 0 )); then
items=( ${(q-)items} )
print -n "${(j: :)items} "
fi
}
# Adapt behaviour to buffer content
if (($CURSOR < _cursor)); then
# Nothing at cursor, restore state before calling nnn
CURSOR=${_cursor}
REGION_ACTIVE=0
zle -U "$(nnn-pick)"
else
# Provide content under cursor to nnn
zle .kill-region
local result="$(nnn-pick ${CUTBUFFER## })"
if (( #result == 0 )); then
# Nothing selected, restore content
zle .yank
else
# Replace content with what nnn returned
zle -U " $result"
fi
fi
# TODO single-op undo
# TODO Handle vicmd properly
zle .redisplay
}
zle -N nnn-file-widget
bindkey -M vicmd '\en' nnn-file-widget
bindkey -M viins '\en' nnn-file-widget
# Whiptail helper
#
# see https://stackoverflow.com/questions/1970180/whiptail-how-to-redirect-output-to-environment-variable
whiptail_checklist() {
autoload zmathfunc; zmathfunc # min, max, sum
eval $(resize) # COLUMNS, LINES
local res title="$1" text="$2"
(( width=max(30, $#text) ))
shift 2
# Make tags compatible with whiptail
local -a tags
for tag; do
tags+=($tag $tag 0)
(( width=max(width, $#tag) ))
done
# Compute "best" width & height
(( list_height=min(20, ${#*}, LINES * .5) ))
(( height=min(list_height+8, LINES) ))
(( width=min(width + 9, COLUMNS * .75) ))
tag=$(whiptail --title $title \
--checklist $text $height $width $list_height $tags \
--separate-output --notags 3>&1 1>&2 2>&3 3>&-)
res=$?
# Use res=${(f)"$(whiptail_checklist...)"} to ignore spaces
echo $tag
return $res
}
whiptail_menu() {
autoload zmathfunc; zmathfunc # min, max, sum
eval $(resize) # COLUMNS, LINES
local res title="$1" text="$2"
(( width=max(30, $#text) ))
shift 2
# Make tags compatible with whiptail
local -a tags
for tag; do
tags+=($tag $tag)
(( width=max(width, $#tag) ))
done
# Compute "best" width & height
(( menu_height=min(20, ${#*}, LINES * .5) ))
(( height=min(menu_height+8, LINES) ))
(( width=min(width + 5, COLUMNS * .75) ))
tag=$(whiptail --title $title \
--menu $text $height $width $menu_height $tags \
--notags 3>&1 1>&2 2>&3 3>&-)
res=$?
echo $tag
return $res
}
###
### Aliases -- Global & automatic expansion
###
@ -355,7 +453,8 @@ HISTORY_IGNORE="(?|??|???|cd [a-zA-Z]*|* --help|#*|builtin *|run-help *)"
# `showkey -a` to print keys
# Undo (useful to cancel completion -- borrowed from emacs keymap)
bindkey "^_" undo
bindkey -M vicmd "^_" undo
bindkey -M viins "^_" undo
###

View File

@ -4,6 +4,14 @@
alias xterm='xterm -bg black -fg white -fa Hack -fs 10'
## Mount dev folders
#
# Note: To be done first, so other actions can use mounted folders.
#
[[ -x $HOME/bin/mount_dev.zsh ]] &&
xterm -geometry 120x40 -title "Mount devices" -hold -e $HOME/bin/mount_dev.zsh
## Start periodic actions
#
$HOME/bin/every-hour.zsh