aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2025-08-02 17:27:38 +0100
committerJustine Smithies <justine@smithies.me.uk>2025-08-02 17:27:38 +0100
commitf8cee8f88d8d60fedb66b9c70f5caaadba7eecae (patch)
tree527c0379088b36a9b7e888a9533781ddc484270c
parentc257c004237ee1e69182e59508486d55ea5a15fb (diff)
Added _exist helper function and setup PAGER
-rw-r--r--.kshrc20
1 files changed, 19 insertions, 1 deletions
diff --git a/.kshrc b/.kshrc
index 47fc7a6..3d2864f 100644
--- a/.kshrc
+++ b/.kshrc
@@ -3,6 +3,11 @@
#
# See also oksh(1)
+# If helpers exist
+_exists() {
+ type $1 > /dev/null 2>&1
+}
+
# Don't do anything if we don't have a prompt (not an interactive shell)
[[ $- != *i* ]] && return || [ -z "$PS1" ] && return
@@ -19,7 +24,7 @@ HISTCONTROL=ignoredups:ignorespace
# Some useful aliases
# If btop is installed then alias top to btop
-[ -e /usr/local/bin/btop ] && alias top="/usr/local/bin/btop"
+_exists && alias top="/usr/local/bin/btop"
alias ls='ls --color=auto -hv'
alias config='/usr/local/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
@@ -39,6 +44,19 @@ __get_current_git_branch_name() {
echo -en " $branch_name"
}
+# Pager
+if _exists less; then
+ PAGER=less
+ LESSHISTFILE=-
+# # -I ignore case
+# # -R colored output
+# # -X don't clear on exit
+# # -Ps string prompt
+ # LESS='-IRXPs %lt-%lb (%Pt-%Pb \%) ░ %bt-%bbb ░ %f ░▒▓'
+ LESS='-IRX'
+ export PAGER LESSHISTFILE LESS
+fi
+
# Colored man pages
man() {
sh -c "man '$@' | col -bx | bat -l man"