diff options
author | Justine Smithies <justine@smithies.me.uk> | 2025-08-02 17:27:38 +0100 |
---|---|---|
committer | Justine Smithies <justine@smithies.me.uk> | 2025-08-02 17:27:38 +0100 |
commit | f8cee8f88d8d60fedb66b9c70f5caaadba7eecae (patch) | |
tree | 527c0379088b36a9b7e888a9533781ddc484270c | |
parent | c257c004237ee1e69182e59508486d55ea5a15fb (diff) |
Added _exist helper function and setup PAGER
-rw-r--r-- | .kshrc | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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" |