From f8cee8f88d8d60fedb66b9c70f5caaadba7eecae Mon Sep 17 00:00:00 2001 From: Justine Smithies Date: Sat, 2 Aug 2025 17:27:38 +0100 Subject: Added _exist helper function and setup PAGER --- .kshrc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to '.kshrc') 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" -- cgit v1.2.3