• beirdobaggins@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    diff -y -W 200 file1 file2

    Shows a side by side diff of 2 files with enough column width to see most of what I need usually.

    I have actually aliased this command as diffy

    ctrl-r

    searching bash history

    du -sh * | sort -h

    shows size of all files and dirs in the current dir and sorts them in ascending order so you can easily see the largest files or dirt ant the end of the list

    ls -ltr

    Shows the most recently modified files at the end of the listing.

        • 7dev7random7@suppo.fi
          link
          fedilink
          arrow-up
          0
          ·
          2 months ago

          Someone who doesn’t know the benefits of dedicated, unlimited scrollback buffers. This command is useful but has a bad effect (when unintentionally).

          • ripcord@lemmy.world
            link
            fedilink
            arrow-up
            0
            ·
            2 months ago

            No, I do. Clearing the scrollback because I want a new, very clear start point for a new activity and don’t care about the rest is frequently the goal.

            If I do care about the history I’ll do something else or possibly been saving history to disk, although that’s far more rare.

  • papertowels@lemmy.one
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    sudo !! to rerun last command as sudo.

    history can be paired with !5 to run the fifth command listed in history.

      • papertowels@lemmy.one
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        2 months ago

        I believe it’s the fifth oldest - I think !-5 will get you the fifth impost recent, but I was shown that and haven’t put it into practice.

        The most common usecase I do is something like history | grep docker to find docker commands I’ve ran, then use ! followed by the number associated with the command I want to run in history.

    • Kelly Aster 🏳️‍⚧️@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 months ago

      @papertowels@lemmy.one I’ve been working in the bash shell since 1993 and did not know sudo !! was a thing. Good lord, I no longer have to press up, press crtl-left a bunch of times, then type sudo enter space anymore. And I can give it an easy-to-remember alias like ‘resu’ or ‘redo’! Ahahaha, this changes everything! Thank you!!

    • Sneezycat@sopuli.xyz
      link
      fedilink
      arrow-up
      0
      ·
      2 months ago

      I just aliased “sudo pacman -Syu && yay -Syu --aur” to “update” cause I got tired of writing it every day.

      • Noxious@fedia.io
        link
        fedilink
        arrow-up
        0
        ·
        2 months ago

        Wouldn’t it make more sense to just yay -Syu to update everything, normal packages and AUR packages?

        • Sneezycat@sopuli.xyz
          link
          fedilink
          arrow-up
          0
          ·
          2 months ago

          The reason I did it like this is because:

          • I didn’t know yay could invoke pacman
          • I didn’t want yay “upgrading” my pacman packages with AUR packages.

          But I was just misunderstanding yay. As another comment said before you, one can just run yay without any arguments and it accomplishes the same thing.

  • RagingRobot@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 months ago

    CTR + u will delete the whole command. I use that a lot so I don’t have to backspace. It’s saved me a ton of time

  • spittingimage@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    2 months ago

    I often play an old DOS game in DOSBox, and when I exit it doesn’t reset the screen resolution. So I reset it manually by typing

    xrandr -output e-DP1 -auto

  • macattack@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    2 months ago

    Getting cheatsheets via curl cheat.sh/INSERT_COMMAND_HERE

    No install necessary, Also, you can quickly search within the cheatsheets via ~. For example if you copy curl cheat.sh/ls~find will show all the examples of ls that use find. If you remove ~find, then it shows all examples of ls.

    I have a function in my bash alias for it (also piped into more for readability):

    function cht() { curl cheat.sh/"$1"?style=igor|more }