Compare commits
9 Commits
56590e1e43
...
ff2cae46be
Author | SHA1 | Date |
---|---|---|
Michel | ff2cae46be | |
Michel | 5312fd7bf2 | |
Michel | e0b9335f2b | |
Michel | 9be893d07f | |
Michel | d45e45e011 | |
Michel | 0756bd5272 | |
Michel | 7df92af4f1 | |
Michel | a1ef675695 | |
Michel | 010ee78078 |
|
@ -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.
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
export NC_STORAGE="$HOME/NC-Michel/Linux/folder"
|
||||
export ALT_HISTORY_FILE="$HOME/NC-Michel/Linux/another-folder/history"
|
|
@ -1,2 +0,0 @@
|
|||
export NC_STORAGE="$HOME/NC-Michel/Linux/VDell"
|
||||
export ALT_HISTORY_FILE="$HOME/NC-Michel/Linux/michdell/history"
|
119
.zshrc
119
.zshrc
|
@ -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
|
||||
|
||||
|
||||
###
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue