For example, things you do often but not often enough to make a muscle memory? On Linux systems with Bash, I just use bash aliases. If I do it more than once, It gets an alias or a script; cause I won’t remember next time. Example of my current desktop aliases :

alias fuck='sudo $(history -p \!\!)'
alias hstat='curl -o /dev/null --silent --head --write-out '\''%{http_code}\n'\'''
alias ls='ls -la --color=auto'
alias pwgen='< /dev/urandom tr -dc "_A-Z-a-z-0-9\#\+=\$" | head -c${1:-15};echo;'
alias rsync='rsync -ah --info=progress2'

And in my bashrc I have the following settings and functions which come in handy when heads down in the terminal:

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
HISTTIMEFORMAT="%Y-%m-%d %T "

####
function stopwatch() {
    local BEGIN=$(date +%s)
    echo Starting Stopwatch...

    while true; do
        local NOW=$(date +%s)
        local DIFF=$(($NOW - $BEGIN))
        local MINS=$(($DIFF / 60))
        local SECS=$(($DIFF % 60))
        local HOURS=$(($DIFF / 3600))
        local DAYS=$(($DIFF / 86400))

        printf "\r%3d Days, %02d:%02d:%02d" $DAYS $HOURS $MINS $SECS
        sleep 0.5
    done
}

function md() {
  pandoc "$1" | lynx -stdin;
}

function weather() {
  ( IFS=+; curl wttr.in/$(curl -s http://ipwho.is/ | jq .postal););
}

So what do you do to remember or recall your most used commands?

  • Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    11
    ·
    10 months ago

    I’m using Fish, rather than Bash, and it has type-ahead suggestions, which help a lot.

    So, I’ll type rsync and then it’ll show inline that I typed rsync -ah --info=progress2 a long time ago. And then I’ll be like, oh wow, this past-me-guy was very smart, I’ll be having the same.

    Obviously, this is an imperfect system. If you run another rsync command without these flags, it won’t directly show these flags next time, because it’s not the most recent entry in history.
    But it’s rare that I know I’ll want to run a command again in a few months, so it’s still really helpful.
    And of course, there is nothing stopping me from creating aliases and scripts as well.

    • TehPers@beehaw.org
      link
      fedilink
      English
      arrow-up
      4
      ·
      10 months ago

      I use nushell, same thing with the suggestions. With nushell, you can also press up/down to traverse through the command history for commands starting with what you typed. For example, you could type ls and press up a bunch to go through ls | where size > 2kb, ls | where type == 'directory', etc (if you’ve executed those before).