• renzev@lemmy.world
    link
    fedilink
    arrow-up
    37
    ·
    6 days ago

    tldr is great. Basically a crowd-sourced alternative to man with much more concise entries. Example:

    $ tldr dhcpcd
    
      DHCP client.
      More information: <https://roy.marples.name/projects/dhcpcd>.
    
      Release all address leases:
    
          sudo dhcpcd --release
    
      Request the DHCP server for new leases:
    
          sudo dhcpcd --rebind
    
  • lud@lemm.ee
    link
    fedilink
    arrow-up
    19
    arrow-down
    1
    ·
    edit-2
    6 days ago

    As primarily a Windows admin (Yes, we exist on Lemmy ;) ) here are few I use often.

    • Enter-PSSesion
    • Get-ADUser (also group and computer)
    • CLS (aka the superior clear)
    • ii . (short for Invoke-Item . which runs the selected object using the default method. For paths (like .) the default is explorer, so ii . opens the current directory using explorer.)
    • ft (short for Format-Table formats piped input as a table.)
    • fl (short for format-like. Used like ft but for lists.)
    • Where-Object
    • Select-Object
  • pemptago@lemmy.ml
    link
    fedilink
    English
    arrow-up
    38
    ·
    7 days 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.

  • zlatiah@lemmy.world
    link
    fedilink
    arrow-up
    31
    ·
    7 days ago

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

    • feddylemmy@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      6 days ago

      I like using CRTL+L to clear. It’s nice because you can have a command typed out and still be able to press CTRL+L to clear the screen and keep the command typed out.

        • zlatiah@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          6 days ago

          Oh god I also do this… See the comment below, I ran history|cut -d " " -f 5|sort|uniq -c|sort -nr|less on my personal laptop, my third most commonly used command (behind ls and cd) is just typing in nothing…

      • BaumGeist@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        6 days ago

        Use script instead, you can even have it in your .*shrc to run automatically whenever a shell is invoked (make sure to add a check that the shell wasn’t invoked by script, so you don’t inadvertently forkbomb yourself)

        Alternatively, just use Terminator as yout terminal emulator and enable the logger anytime you need it to record the shell session.

        Also, use bookmarks. That’s what they’re there for. 100 tabs is a great way to clutter your brain, but terrible for productivity. If you forget about it after bookmarking, it wasn’t important to begin with.

        • mexicancartel@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          1
          ·
          6 days ago

          100 tabs is in mobile. I don’t even scroll back to clutter my brain but its there. Tabs are history for me… So I use firefox focus and if there is anything important, i open with firefox.

          What script are you reffering to? To log all output? I don’t wanna store that but need an assurance that its there till i close terminal window lol

  • lluki@feddit.org
    link
    fedilink
    arrow-up
    14
    ·
    7 days 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).

  • Dr. Moose@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    6 days ago

    I really like how nushell can parse output into it’s native structures called tables using the detect command.

    Unlike string outputs, tables allow for easy data manipulation through pipes like select foo will select foo key and you can filter and even reshape the datasets.

    This is great if you need to work with large data pipes like kuberneters so you can do something like:

    kubectl get pods --all-namespaces | detect columns | where $it.STATUS !~ "Running|Completed" | par-each { |it| kubectl -n $it.NAMESPACE delete pod $it.NAME }
    

    This looks complex but it parses kubectl table string to table object -> filters rows only where status is not running or completed -> executes pod delete task for each row in parallel.

    Nushell take a while to learn but having real data objects in your terminal pipes is incredible! Especially with the detect command.

    There’s are few more shells that do that though nu is the most mature one I’ve seen so far.

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

  • NauticalNoodle@lemmy.ml
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    6 days ago

    For Debian based/descended distros:

    sudo apt-get update && sudo apt-get upgrade
    

    And technically I also regularly use

    redshift -O 3000
    

    all of the blue light filter programs try to align themselves with a user’s geographic location and time, but I don’t keep normal hours

      • NauticalNoodle@lemmy.ml
        link
        fedilink
        arrow-up
        6
        ·
        6 days ago

        I would but much like somebody else’s recent post I have in the past nuked my install by blindly agreeing to some recommended software removals before. These days I like to double check what packages are being updated and replaced.

  • Caveman@lemmy.world
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    6 days ago

    g-push which is alias for

    git push origin `git branch --show`
    

    Which I’m writing on my phone without testing or looking

        • JackbyDev@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          5 days ago

          When you’re pushing a new branch you’ve never pushed before you need the -u command. That’s what this alias is for.

          As long as the config’s push.default isn’t matching, git push without arguments will only push the current branch.