this post was submitted on 25 Dec 2023
21 points (100.0% liked)

Operating Systems

3793 readers
1 users here now

All things operating system related, from Windows to Mac to Linux distros and the more obscure.

Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 5 points 10 months ago (1 children)

Not the OP and not an expert, but it looks like it redoes the last command with sudo. Would be very useful since I use sudo !! quite often.

[โ€“] [email protected] 4 points 10 months ago (1 children)

Oh, nice! I thought sudo !! was short enough ๐Ÿ˜†

[โ€“] [email protected] 3 points 10 months ago

I agree. But I love the fact that it was aliased to fuck. I just use stuff like up for updating or in installing. Haven't gotten creative with them yet.