• beirdobaggins@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    3 hours 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.

  • I Cast Fist@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    4 hours ago

    More of a shortcut, CTRL + A + D to exit the current session (exits a sudo su first, then a ssh, then the actual terminal)

  • Bob@feddit.nl
    link
    fedilink
    arrow-up
    1
    ·
    4 hours ago

    I use “ping” every time I suspect my internet might be going a bit slow.

  • lluki@feddit.org
    link
    fedilink
    arrow-up
    10
    ·
    7 hours ago

    xdg-open FILE - opens a file with the default GUI app. I use it for example to open PDFs and PNG. I have a one letter alias for that. It can also open a file explorer in the current directory xdg-open . . Should work on any compliant desktop environment (gnome/kde).

  • zlatiah@lemmy.world
    link
    fedilink
    arrow-up
    20
    ·
    14 hours ago

    clear because apparently I am too scatterbrained to comprehend more than one full page of text in the terminal

  • pemptago@lemmy.ml
    link
    fedilink
    English
    arrow-up
    25
    ·
    16 hours ago

    I went a little overboard and wrote a one-liner to accurately answer this question

    history|cut -d " " -f 5|sort|uniq -c|sort -nr|head -5
    

    Note: history displays like this for me 20622 2023-02-18 16:41:23 ls I don’t know if that’s because I set HISTTIMEFORMAT='%F %T ' in .bashrc, or if it’s like that for everyone. If it’s different for you change -f 5 to target the command. Use -f 5-7 to include flags and arguments.

    My top 5 (since last install)

       2002 ls
       1296 cd
        455 hx
        427 g
        316 find
    

    g is an alias for gitui. When I include flags and arguments most of the top commands are aliases, often shortcuts to a project directory.

    Not to ramble, but after doing this I figured I should alias the longest, most-used commands (even aliasing ls to l could have saved 2002 keystrokes :P) So I wrote another one-liner to check for available single characters to alias with:

    for c in a b c d e f g h i j k l m n o p q r s t u v w x y z; do [[ ! $(command -v $c) ]] && echo $c; done
    

    In .bash_aliases I’ve added alias b='hx ${HOME}/.bash_aliases' to quickly edit aliases and alias r='source ${HOME}/.bashrc' to reload them.

      • pemptago@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        12 hours ago

        Yup! Migrated from VSCodium; wanted to learn a modal editor but didn’t have the time or confidence to configure vim or neovim. It’s been my go-to editor for 2+ years now.

        • MigratingtoLemmy@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          12 hours ago

          I’ve been using vi (just the basics) for ~4 years, I don’t think I could be arsed to pick up the keybindings the other way around lol. I’ve heard very good things about Helix, of course

          • HeartyOfGlass@lemm.ee
            link
            fedilink
            English
            arrow-up
            1
            ·
            3 hours ago

            As another longtime Vi user - I had a hell of a time & wound up switching back lol

            I think for a lot of folks Helix would be intuitive. Vi has her hooks in me, though.

  • Jess@lemmy.world
    link
    fedilink
    arrow-up
    28
    ·
    17 hours ago

    tldr because I am too impatient to read through man pages or google the exact syntax for what I want to do.

    • pixelscript@lemm.ee
      link
      fedilink
      English
      arrow-up
      18
      ·
      16 hours ago

      There are exactly three kinds of manpages:

      1. Way too detailed
      2. Not nearly detailed enough
      3. There is no manpage

      I will take 1 any day over 2 or 3. Sometimes I even need 1, so I’m grateful for them.

      But holy goddamn is it awful when I just want to use a command for aguably its most common use case and the flag or option for that is lost in a crowd of 30 other switches or buried under some modal subcommand. grep helps if you already know the switch, which isn’t always.

      You could argue commands like this don’t have “arguably most common usecases”, so manpages should be completely neutral on singling out examples. But I think the existence of tl;dr is the counterargument.

      Tangent complaint: I thought the Unix philosophy was “do one thing, and do it well”? Why then do so many of these shell commands have a billion options? Mostly /s but sometimes it’s flustering.

          • wuphysics87@lemmy.ml
            link
            fedilink
            arrow-up
            1
            ·
            21 minutes ago

            I can appreciate that. Appologies if you know this already, but just don’t like them. Here are some tips.

            It helps a lot to get title/subtitle/flag highlighting. By default man pages are hard to use simply because of how dense they are. It’s much easier to skim when you can separate the parts you are looking for up front from the text.

            Don’t forget ‘/’, ‘n’, and ‘N’. First way to use man pages more effectively is to search them easily. And you can search via regex. Often I’m looking for more info on a particular flag. So I’ll press ‘/’ followed by ‘^ *-g’. For a g flag.

            Take notes on the side. It saves you time later. Your future self will thank you. And you learn a lot by skimming them.

            Man pages can be intimidating/confusing, but, imho, it’s worth training that skill. Even if you are slower up front, it’s totally worth it.