summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <ivi@vinkies.net>2025-02-09 19:49:29 +0100
committerMike Vink <ivi@vinkies.net>2025-02-09 19:49:29 +0100
commitc777225918e964e3a52ced1848a4ef0f58408503 (patch)
tree51699b8ecbceb8b98e9e0b9f39aee5f1bbb6eba1
parent439dc96e5a80cc15952cded1f432185ed97f8c69 (diff)
update
-rw-r--r--.config/ksh/ksh.kshrc22
-rw-r--r--.config/lf/lfrc7
-rw-r--r--.config/shell/profile11
-rw-r--r--.config/vis/visrc.lua40
-rw-r--r--.kshrc2
-rw-r--r--.profile1
6 files changed, 51 insertions, 32 deletions
diff --git a/.config/ksh/ksh.kshrc b/.config/ksh/ksh.kshrc
new file mode 100644
index 0000000..1868212
--- /dev/null
+++ b/.config/ksh/ksh.kshrc
@@ -0,0 +1,22 @@
+lfcd () {
+ tmp="$(mktemp -uq)"
+ trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT
+ lf -last-dir-path="$tmp" "$@"
+ if [ -f "$tmp" ]; then
+ dir="$(cat "$tmp")"
+ [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
+ fi
+}
+bind -m ^O=' lfcd^J'
+
+# Emacs mode clear chops off multline prompts.
+export PS1="$(hostname):/\$(
+pwd | cut -d'/' -f2- --output-delimiter '
+' | cut -c1-3 | paste -sd '/'
+)\$(prompt-git)\n# "
+bind -m ^L="^A^K clear^J"
+
+export HISTFILE="$HOME/.history"
+export HISTCONTROL=ignorespace
+set -o emacs
+
diff --git a/.config/lf/lfrc b/.config/lf/lfrc
index e34d8c3..bb86a04 100644
--- a/.config/lf/lfrc
+++ b/.config/lf/lfrc
@@ -16,8 +16,9 @@
# called directly instead of normal lf.
# Basic vars
-set shellopts '-eu'
+# set shellopts '-eu'
set ifs "\n"
+set hidden
set scrolloff 10
set icons
set period 1
@@ -120,7 +121,7 @@ cmd bulkrename ${{
tmpfile_old="$(mktemp)"
tmpfile_new="$(mktemp)"
- [ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls)
+ [ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls -A)
echo "$fs" > "$tmpfile_old"
echo "$fs" > "$tmpfile_new"
@@ -146,7 +147,7 @@ cmd on-quit ${{
fi
}}
-cmd change-last-dir &{{
+cmd change-last-dir ${{
echo "$PWD" > /tmp/lf-on-quit
}}
diff --git a/.config/shell/profile b/.config/shell/profile
index ee2e117..d7ac043 100644
--- a/.config/shell/profile
+++ b/.config/shell/profile
@@ -1,9 +1,4 @@
-export HISTFILE="$HOME/.history"
-export HISTCONTROL="ignorespace"
+export EDITOR=vis
+
+export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin
-# Emacs mode clear chops off multline prompts.
-export PS1="$(hostname):/\$(
-pwd | cut -d'/' -f2- --output-delimiter '
-' | cut -c1-3 | paste -sd '/'
-) \$(prompt-git)\n# "
-bind -m ^L=" clear^J"
diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua
index 4f87b50..69a16a9 100644
--- a/.config/vis/visrc.lua
+++ b/.config/vis/visrc.lua
@@ -75,34 +75,34 @@ local parent = function(filename)
return nil
end
-local lfcd = function(cd_or_select_path)
- local code, result, err = vis:pipe("", "lf --print-selection " .. cd_or_select_path)
- vis:command("cd " .. err)
- if result then
- vis:command("e " .. result)
+-- Only works on linux for now.
+local pcwd = function()
+ local stat = io.open("/proc/self/stat"):read("*a")
+ local fields = {}
+ for k in stat:gmatch("[^%s]+") do table.insert(fields, k) end
+ if not fields[4] then
+ return "."
end
- return true;
+ local parent_cwd = "/proc/" .. fields[4] .. "/cwd"
+ vis:info(parent_cwd)
+ return parent_cwd
end
vis:map(m.NORMAL, "<C-x>~", function()
- vis:command("cd " .. (parent(vis.win.file.path) or "."))
+ vis:command("cd " .. pcwd())
return true;
end)
-vis:map(m.NORMAL, "<C-x><C-f>", function()
- local code, result, err = vis:pipe("", "vis-open " .. (parent(vis.win.file.path) or "."))
+vis:map(m.NORMAL, "<C-x>_", function()
+ local code, result, err = vis:pipe("vis-open .")
if result then
- if not os.execute("cd " .. result) then
- vis:command("e " .. result)
- else
- return lfcd(result)
- end
- return true;
+ vis:command("e " .. result)
end
return true;
end)
-vis:map(m.NORMAL, "<C-x>-", function()
- return lfcd(parent(vis.win.file.path) or "")
-end)
-vis:map(m.NORMAL, "<C-x>_", function()
- return lfcd(".")
+vis:map(m.NORMAL, "<C-x><C-f>", function()
+ local code, result, err = vis:pipe("vis-open " .. (parent(vis.win.file.path) or "."))
+ if result then
+ vis:command("e " .. result)
+ end
+ return true;
end)
diff --git a/.kshrc b/.kshrc
index 2ea7644..8f2463d 100644
--- a/.kshrc
+++ b/.kshrc
@@ -1,2 +1,2 @@
[ -f /etc/ksh.kshrc ] && . /etc/ksh.kshrc
-[ -f "$HOME/.config/ksh/ksh.kshrc" ] && . "$HOME/.config/shell/profile"
+[ -f "$HOME/.config/ksh/ksh.kshrc" ] && . "$HOME/.config/ksh/ksh.kshrc"
diff --git a/.profile b/.profile
index 8cd2ee7..4d33e71 100644
--- a/.profile
+++ b/.profile
@@ -1,4 +1,5 @@
export ENV=$HOME/.kshrc
+[ -f "$HOME/.config/shell/profile" ] && . "$HOME/.config/shell/profile"
if [ -z $DISPLAY ] && [ $(tty) = /dev/tty1 ]; then
startx
fi