From d52f002785c1a7c1528dc94f06812dc433f7a784 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 9 Jun 2021 18:30:23 +0200 Subject: Add shortcuts for head/tail. --- bash/bashrc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bash/bashrc b/bash/bashrc index 2947bf0..09d6a95 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -55,6 +55,23 @@ cu() cd "${dir}" } +# head/tail shortcut +# e.g. "lt|h" or "h lt" +__ht() +{ + local cmd=$1 + shift + + if [ $# -ne 0 ]; then + $@ | $cmd + else + $cmd + fi +} + +h() { __ht "head -32" $@; } +t() { __ht "tail -32" $@; } + # define the prompt . ~/.config/bash/prompt PS1=$(__prompt_func) -- cgit v1.2.3