1
0
Fork 0
This commit is contained in:
Luca Bilke 2024-02-01 11:35:13 +01:00
commit 035b5a4f48
7 changed files with 69 additions and 30 deletions

View file

@ -21,35 +21,40 @@
}, },
"h1": { "h1": {
"prefix": "▋ ", "prefix": "▋ ",
"block_suffix": "\n",
"color": "#89ddff", "color": "#89ddff",
"bold": true, "bold": true
"block_suffix": "\n"
}, },
"h2": { "h2": {
"prefix": "▌ ", "prefix": "▌ ",
"block_suffix": "\n",
"color": "#61bdf2", "color": "#61bdf2",
"bold": true "bold": true
}, },
"h3": { "h3": {
"prefix": "┃ ", "prefix": "┃ ",
"block_suffix": "\n",
"color": "#82aaff", "color": "#82aaff",
"bold": true "bold": true
}, },
"h4": { "h4": {
"prefix": "│ ", "prefix": "│ ",
"block_suffix": "\n",
"color": "#6d91de", "color": "#6d91de",
"bold": true "bold": true
}, },
"h5": { "h5": {
"prefix": "┆ ", "prefix": "┆ ",
"block_suffix": "\n",
"color": "#9aa5ce", "color": "#9aa5ce",
"bold": true "bold": true
}, },
"h6": { "h6": {
"prefix": "┊ ", "prefix": "┊ ",
"block_suffix": "\n",
"color": "#61bdf2" "color": "#61bdf2"
}, },
"text": { "text": {

View file

@ -11,47 +11,58 @@ set previewer "~/.config/lf/preview/chafa"
set cursorpreviewfmt "\033[7;90m" set cursorpreviewfmt "\033[7;90m"
set promptfmt "\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m%d\033[35m]\033[32m » \033[33m%f\033[0m" set promptfmt "\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m%d\033[35m]\033[32m » \033[33m%f\033[0m"
cmd open ${{
set -f
rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -p 0 $f
clear
}}
cmd pushedit %{{ cmd pushedit %{{
echo "Open: " echo "Open: " && read files
files=$(read x; echo $x)
lf -remote "send $id unselect"
if sh -c '[ -n "$VIM" ]'; then if sh -c '[ -n "$VIM" ]'; then
lf -remote "send $id vimopen $files" lf -remote "send $id vimopen $files"
else else
lf -remote "send $id \$echo $files | xargs -or \$EDITOR" lf -remote "send $id \$echo $files | xargs -or nvim +wa"
fi fi
lf -remote "send $id reload"
}} }}
cmd edit &{{ cmd edit ${{
if sh -c "[ -n '\$VIM' ]"; then if sh -c "[ -n \"\$VIM\" ]"; then
lf -remote "send $id vimopen $fx" lf -remote "send $id vimopen $fx"
else else
lf -remote "send $id '\$echo $fx | xargs -or nvim +wa'" lf -remote "send $id \$echo \$fx | xargs -or nvim +wa"
fi fi
}} }}
cmd open-with ${{ cmd open-with ${{
method=$(rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -l $fx | fzf | cut -d':' -f1) method=$(rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -l $fx | fzf --header="Choose an application:" | cut -d':' -f1)
rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -p $method $fx rifle -c $XDG_CONFIG_HOME/lf/rifle.conf -p $method $fx
}} }}
cmd vimopen &{{
touch "$@"
lf -remote "$(
for f in "$@"; do printf "%b" "send $id toggle $f\n"; done
printf "%b" "send $id select $f\n"
printf "%b" "send $id open\n"
printf "%b" "send $id unselect\n"
)"
}}
cmd mkdir &mkdir -p "$(echo $* | tr ' ' '\ ')" cmd mkdir &mkdir -p "$(echo $* | tr ' ' '\ ')"
cmd trash &{{ cmd trash &{{
for f in $fx; do for f in $fx; do
trash-put $f & trash-put $f &
done done
lf -remote "send $id load" lf -remote "send load"
}} }}
cmd lazygit ${{ cmd lazygit %{{
cd "$(dirname "$(realpath "$f")")" && lazygit dir=$(dirname "$(realpath "${f:-_}")"})
if ! git --noglob-pathspecs -C $dir status >/dev/null 2>&1; then
echo "Initialize git repo in '${dir}' [Y/n]:" && read yn &&
case $yn in
"" | [Yy]*) git -C ${dir} init >/dev/null 2>&1; break ;;
[Nn]*) ;;
esac
fi
lf -remote "send $id \$cd '$dir' && lazygit"
}} }}
# y (select for copy) and P to paste soft-link # y (select for copy) and P to paste soft-link
@ -119,22 +130,22 @@ cmd dupe &{{
# cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c # cmd share $curl -F"file=@$fx" https://0x0.snaile.de | xclip -r -selection c
cmd fzfsearch ${{ cmd fzfsearch ${{
file="$(find $PWD | fzf)" file="$(find -L $PWD | fzf --header="Searching Filenames")"
[ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -d $file ] && lf -remote "send $id cd $file" && return 0
[ -f $file ] && lf -remote "send $id select $file" [ -f $file ] && lf -remote "send $id select $file"
}} }}
cmd fzftags ${{ cmd fzftags ${{
file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/tags | sed 's/:\*$//' | fzf)" file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/tags | sed 's/:\*$//' | fzf --header="Searching Tags")"
[ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -d $file ] && lf -remote "send $id cd $file" && return 0
[ -f $file ] && lf -remote "send $id select $file" [ -f $file ] && lf -remote "send $id select $file"
}} }}
cmd fzfmarks ${{ cmd fzfmarks ${{
file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/marks | sed 's/^.://' | fzf)" file="$(cat ${XDG_DATA_HOME:-$HOME/.local/share}/lf/marks | sed 's/^.://' | fzf --header="Searching Marks")"
[ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -d $file ] && lf -remote "send $id cd $file" && return 0
[ -f $file ] && lf -remote "send $id select $file" [ -f $file ] && lf -remote "send $id select $file"
}} }}
cmd fzfshortcut ${{ cmd fzfshortcut ${{
file="$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc | cut -d '"' -f2 | fzf)" file="$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc | cut -d '"' -f2 | fzf --header="Searching Shortcuts")"
[ -d $file ] && lf -remote "send $id cd $file" && return 0 [ -d $file ] && lf -remote "send $id cd $file" && return 0
[ -f $file ] && lf -remote "send $id select $file" [ -f $file ] && lf -remote "send $id select $file"
}} }}
@ -143,15 +154,17 @@ cmd fzfgrep ${{
res="$( res="$(
FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \ FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \
fzf --bind "change:reload:$RG_PREFIX {q} || true" \ fzf --bind "change:reload:$RG_PREFIX {q} || true" \
--ansi --layout=reverse --header 'Search in files' |\ --ansi --layout=reverse --header 'Searching file contents' |\
grep -iv -e 'Trash/files' -e 'Trash/info' grep -iv -e 'Trash/files' -e 'Trash/info'
)" )"
file="$(echo $res | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')" file="$(echo $res | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g')"
row="$(echo $res | cut -d':' -f2)" row="$(echo $res | cut -d':' -f2)"
column="$(echo $res | cut -d':' -f3)" column="$(echo $res | cut -d':' -f3)"
if [ -n "$res" ]; then if [ -n "$res" ]; then
lf -remote "send ${id} select '$file'" lf -remote "send $id select '$file'"
if [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then if [ -n "$VIM" ]; then
lf -remote "send $id open '$file'"
elsif [ "$EDITOR" = "nvim" ] || [ "$EDITOR" = "vim" ]; then
lf -remote "send $id \$$EDITOR '$file' +'call cursor($row, $column)'" lf -remote "send $id \$$EDITOR '$file' +'call cursor($row, $column)'"
else else
lf -remote "send $id \$$EDITOR '$file'" lf -remote "send $id \$$EDITOR '$file'"
@ -190,7 +203,7 @@ cmd set_previewer %{{
# HACK: This is a dirty hack to have an lf terminal that I can "exit" out of into a shell # HACK: This is a dirty hack to have an lf terminal that I can "exit" out of into a shell
cmd new_lf_term &{{ cmd new_lf_term &{{
mapcmd='map q $tmux' mapcmd='map q $sh -c "tmux; kill $id"'
previewercmd="set_previewer $(basename "$lf_previewer")" previewercmd="set_previewer $(basename "$lf_previewer")"
$TERMINAL -e lf -command "${previewercmd}; ${mapcmd}" $TERMINAL -e lf -command "${previewercmd}; ${mapcmd}"
}} }}
@ -208,7 +221,7 @@ map <c-e> extract
map P link map P link
# map S share # map S share
map <c-g> lazygit map <c-g> lazygit
map <c-v> push :!$EDITOR<space> map <c-v> pushedit
map <c-n> push :mkdir<space> map <c-n> push :mkdir<space>
map N push :&touch<space> map N push :&touch<space>
map <c-r> reload map <c-r> reload
@ -228,7 +241,7 @@ map n &echo $f | xclip -r -selection c
map <esc> quit map <esc> quit
map g/ cd "/" map g/ cd "/"
map W new_lf_term map W new_lf_term
map e $$EDITOR $f map e edit
map E $sudo -e $f map E $sudo -e $f
# Load bookmark shortcuts # Load bookmark shortcuts

View file

@ -1 +1,6 @@
gpg asks for unlock when viewing gpg keys gpg asks for unlock when viewing gpg keys
rework rifle.conf
look into perl-File-MimeInfo
look into mimeo
Get the swallow patch up and running asap!
inode/directory handler for forking/terminal

View file

@ -6,7 +6,7 @@ local opts = {
style = "night", style = "night",
transparent = true, transparent = true,
on_highlights = function(hl, _) on_highlights = function(hl, _)
hl.CurSearch = nil hl.CurSearch = { link = "Search" }
end, end,
} }

View file

@ -5,3 +5,6 @@ dir = "~/Documents/wiki"
language = "en" language = "en"
filename = "{{slug title}}-{{id}}" filename = "{{slug title}}-{{id}}"
extension = "md" extension = "md"
[tool]
fzf-preview = "glow -s '$XDG_CONFIG_HOME/glow/style.json' {-1}"

View file

@ -6,6 +6,8 @@
export EDITOR="nvim" export EDITOR="nvim"
export TERMINAL="st" export TERMINAL="st"
export TERMCMD=$TERMINAL
export OPENER=opener
export BROWSER="brave-browser" export BROWSER="brave-browser"
# Locale # Locale

11
.local/bin/opener Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
set -f
if [ "$2" ]; then
for f in "$@"; do
# shellcheck disable=2086
rifle -c "$XDG_CONFIG_HOME/lf/rifle.conf" -p 0 $f
done
else
rifle -c "$XDG_CONFIG_HOME/lf/rifle.conf" -p 0 "$1"
fi