git alias using $((LINES / 2))

I have tried roughly 30 variants of this, including sh -c versions, double and single quotes, nested quotes, etc. What am I missing?

shortlog = "!git log -n $((LINES / 2))"

  • Is it possible to use alias expansion with shell's builtin commands in Git?
  • How to reference remote repositories in a git alias?
  • Bash git alias tab completion error
  • In Git is it possible to refer an alias from another alias
  • Write a git alias for fast forward that works in any tracking branch?
  • Adding Git Bash Alias
  • Why does running command as git alias gives different results?
  • How to highlight files in the side bar that have been modified since the last commit with Git in Sublime Text 3 (like Atom does )?
  • why .gitignore not works?
  • Android-Studio git over ssh
  • How to cherry pick from branch A to branch B on a system without history?
  • Git how to give people push access that needs to be merged in by organizers?
  • 2 Solutions collect form web for “git alias using $((LINES / 2))”

    What if you define a function?

    function shortlog { tmp=$(($LINES / 2)); git log -n "$tmp"; }

    then export it:

    export -f shortlog

    You should put it in your .bashrc I guess if you want to use it each time you start a terminal (but you can first try it on a isolated sterminal of course).


    does this help?

    git config alias.shortlog '!f() { tmp=$(($LINES / 2)); git log -n "$tmp"; }; f'

    I don’t love how I finally got this to work, but it’s literally the only thing that’s worked at all, and I want this to be over. I removed everything relating to the shorter log aliases from my ~/.gitconfig, and in my ~/scripts folder – which is in my $PATH – I made files with names like git-las (list all short), with code like this in each:

    $height=$(tput lines)
    $height=$((height / 3))
    git la -$height

    I made each executable. Git will take git las and find git-las (no extension) on my path, if its executable, and execute it, and it works. That git la (list all) is in my ~/.gitconfig, and is just the typical git log --all --oneline --graph --decorate everyone gives their own name to. This is the only thing that works, after easily 100 variations on every bit of online info I could find. Even trying to move the tput stuff back into ~/.gitconfig fails, and $LINES also fails in these working files; it’s always 0.

    What a battle, but now I have short logs (a few different sizes and settings) that scale dynamically with the window to always give me roughly 1/2 to 1/4 oneline log output – dividing by 3 (and 6 for 1/4) accounts for some extra space around merge commits and tricky branch pathways. I’ve had these hard-coded for a year, but now I’m starting to properly version and share my dotfiles between machines, so I wanted it dynamic for all my different monitor heights, and so it would work in an expected fashion no matter how big I had the window.

    Git Baby is a git and github fan, let's start git clone.