this post was submitted on 13 Aug 2024
15 points (100.0% liked)

Linux

47237 readers
3343 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

You can use cheat sh web service to show cheatsheets for all kind of commands. Just replace the command name: curl -s cheat.sh/date. I also wrote a a simple script with filename being just a question mark to get a working command as ?, that shows all commands in fzf menu if no argument is given or shows the cheatsheet in the less pager if command name is given.

Usage:

?
? -l
? date
? grep

Script ?:

#!/bin/env bash

cheat='curl -s cheat.sh'
menu='fzf --reverse'
pager='less -R -c'
cachefile_max_age_hours=6

# Path to temporary cache file. If your Linux system does not support /dev/shm
# or if you are on MacOS, then change the path to your liking:
cachefile='/dev/shm/cheatlist'      # GNU+LINUX
# cachefile="${TMPDIR}/cheatlist"   # MacOS/Darwin

# Download list file and cache it.
listing () {
    if [ -f "${cachefile}" ]
    then
        local filedate=$(stat -c %Y -- "${cachefile}")
        local now=$(date +%s)
        local age_hours=$(( (now - filedate) / 60 / 60 ))
        if [[ "${age_hours}" > "${cachefile_max_age_hours}" ]]
        then
            ${cheat}/:list > "${cachefile}"
        fi
    else
        ${cheat}/:list > "${cachefile}"
    fi
    cat -- "${cachefile}"
}

case "${1}" in
    '')
        if selection=$(listing | ${menu})
        then
            ${cheat}/"${selection}" | ${pager}
        fi
        ;;
    '-h')
        ${cheat}/:help | ${pager}
        ;;
    '-l')
        listing
        ;;
    *)
        ${cheat}/${@} | ${pager}
        ;;
esac
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here