]> Freerunner's - dotfiles.git/commitdiff
bash/lf: make env more robust
authorAndre Ramnitz <tux.rising@gmail.com>
Fri, 29 Dec 2023 15:22:12 +0000 (16:22 +0100)
committerAndre Ramnitz <tux.rising@gmail.com>
Sun, 18 Aug 2024 16:18:52 +0000 (18:18 +0200)
config/fish/functions/lf.fish
config/lf/lfrc
home/.bashrc
local/bin/lfrun [new file with mode: 0755]

index 7193d12bbd2f44b967edf2adb31f0edc4a9645a6..9b2e4b4e182661ad9e03a219bb3fb7970532c3a9 100644 (file)
@@ -1,3 +1,3 @@
-function lf --wraps=lfimg --description 'alias lf=lfimg'
-  lfimg $argv; 
+function lf --wraps=lfrun --description 'alias lf=lfrun'
+  lfrun $argv; 
 end
index f76c928424babbaf2518add34b3c894153aa181e..4a5ae92b48856ac0bf75445335697eacdeeebdb9 100644 (file)
@@ -4,7 +4,7 @@ set previewer ~/.config/lf/previewer.sh
 set cleaner ~/.config/lf/clear_img.sh
 
 # interpreter for shell commands
-set shell bash
+set shell sh
 
 # set '-eu' options for shell commands
 # These options are used to have safer shell commands. Option '-e' is used to
index 064ed2008ab4d198d79c112b730ae69eb78ff281..7e0b1eda8d5a129d1e9d3ce9cfa7ae4111580e16 100644 (file)
@@ -6,28 +6,27 @@
 # that can't tolerate any output.  So make sure this doesn't display
 # anything or bad things will happen !
 
-export PATH="$PATH:/opt/android-sdk/platform-tools/"
-export PATH="$PATH:~/go/bin:~/.cargo/bin:~/.local/bin:~/Applications/"
+export PATH="$PATH:/opt/android-sdk/platform-tools:$HOME/go/bin:$HOME/.cargo/bin:$HOME/.local/bin:$HOME/Applications"
 
-export BROWSER='qutebrowser "--untrusted-args %u"'
-export EDITOR="kks edit"
-export VISUAL="kks edit"
+export BROWSER='qutebrowser --untrusted-args "%u"'
+export EDITOR='kks edit'
+export VISUAL='kks edit'
+export PAGER='bat --style auto'
 export KKS_DEFAULT_SESSION='default'
 export KKS_USE_GITDIR_SESSIONS=1
-export PAGER="bat --style auto"
-export VDPAU_DRIVER="radeonsi"
-export XZ_OPT="--threads=16"
+export VDPAU_DRIVER='radeonsi'
+export XZ_OPT='--threads=16'
 
 alias grep='grep -i'
-alias gg="cd $(git rev-parse --show-toplevel)"
-alias gco="git checkout"
-alias gcp="git cherry-pick"
-alias glo="git log --oneline"
-alias gst="git status"
+alias gg='cd "$(git rev-parse --show-toplevel)"'
+alias gco='git checkout'
+alias gcp='git cherry-pick'
+alias glo='git log --oneline'
+alias gst='git status'
 alias nano='nano -_qpT4 '
 alias free='free -h --si'
 
-alias lf=lfimg
+alias lf='lfrun'
 alias ls='exa --icons --time-style=iso --group-directories-first'
 alias ll='exa --icons --group --time-style=iso --group-directories-first -l'
 alias l1='exa --icons --group -1 --grid --time-style=iso --group-directories-first'
@@ -37,18 +36,11 @@ alias lt='exa --icons --group --long --sort=mod -t=mod --time-style=iso --group-
 
 alias emergelog='sudo cat /var/log/emerge.log | grep "started\|completed\|exiting"'
 
-alias K='kcr-fzf-shell'
-alias KK='K --working-directory .'
-
-# Open files _from_ and _to_ a session.
-# $ :f src
-# $ f: mawww/kakoune
-alias :f='kcr fzf files'
-alias f:='KK kcr fzf files'
-alias fm:='K sidetree --working-directory'
-
-alias :g='kcr fzf grep'
-alias g:='KK kcr fzf grep'
+alias k='kks edit'
+alias ka='kks attach'
+alias kcd='cd $(kks get %sh{pwd})'
+alias kkd='kks kill; unset KKS_SESSION KKS_CLIENT'
+alias ks='kks-select'
 
 # Test for an interactive shell.  There is no need to set anything
 # past this point for scp and rcp, and it's important to refrain from
diff --git a/local/bin/lfrun b/local/bin/lfrun
new file mode 100755 (executable)
index 0000000..ab0e80c
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+set -e
+
+BROWSER="$(printf "qutebrowser\n--untrusted-args\n%u")"
+EDITOR="$(printf "kks\nedit")"
+VISUAL="$(printf "kks\nedit")"
+PAGER="$(printf "bat\n--style\nauto")"
+
+if [ -n "$DISPLAY" ]; then
+  export FIFO_UEBERZUG="${TMPDIR:-/tmp}/lf-ueberzug-$$"
+
+  cleanup() {
+    exec 3>&-
+    rm "$FIFO_UEBERZUG"
+  }
+
+  mkfifo "$FIFO_UEBERZUG"
+  ueberzugpp layer -s <"$FIFO_UEBERZUG" &
+  exec 3>"$FIFO_UEBERZUG"
+  trap cleanup EXIT
+
+  if ! [ -d "$HOME/.cache/lf" ]; then
+    mkdir -p "$HOME/.cache/lf"
+  fi
+
+  /usr/bin/lf "$@" 3>&-
+else
+  exec /usr/bin/lf "$@"
+fi
+