this post was submitted on 15 Jun 2023
20 points (100.0% liked)

commandline

1696 readers
1 users here now

founded 1 year ago
MODERATORS
 

Any extra tips or tricks are welcome!

Yesterday I learned that set -x enables trace for a bash, sh, or zsh script and prints the trace to the terminal.

top 22 comments
sorted by: hot top controversial new old
[–] gamma 6 points 1 year ago* (last edited 1 year ago)

pv, which is like cat, simply copying files or stdin to stdout, but prints statistics to the terminal.

A related tip: dd isn't special in the way most people use it. This works too, if you're root: pv my-fav-distro.iso > /dev/sdc

[–] sisyphean 6 points 1 year ago (1 children)

I really like jless. You can pipe the JSON output of a cURL command into it and it displays it in a really nice, easy to read way with collapsible arrays and objects.

[–] [email protected] 1 points 1 year ago

Why haven't I heard of this before?? Absolute gamechanger o_O

[–] [email protected] 6 points 1 year ago (1 children)
[–] chaoticAnimals 1 points 1 year ago

Interesting :)

[–] [email protected] 4 points 1 year ago

Taskwarrior.

[–] Algae 4 points 1 year ago* (last edited 1 year ago)

My answers (mostly running in powershell - not that it makes much of a difference!)

Rust-based utilities I couldn't live without:

  • fd (fd-find) for finding my files
  • rg (ripgrep) for string searches
  • sd (sed) for search and replace
  • dust (dust) for information about my directories
  • lsd (aliased to ls or l) for replacing Dir
  • bat (better cat) - for when the help pages are too long

Other stuff I love:

  • htop - I just learned you can run this in WSL to see all your system cores. It's pretty!
  • nvim - obviously. The best vim. Even works in VSCode
[–] chaoticAnimals 4 points 1 year ago* (last edited 1 year ago) (2 children)

I'm a pretty big fan of icdiff. This utility allows you to compare two files to see what has been added or removed by using colorful fonts to highlight values.

https://github.com/jeffkaufman/icdiff

[–] cd_slash_rmrf 3 points 1 year ago (1 children)

I recently learned about diffsitter which uses tree-sitter for meaningful diffs

[–] chaoticAnimals 1 points 1 year ago
[–] Andy 3 points 1 year ago* (last edited 1 year ago)

Another good one is riff (riffdiff on crates.io).

EDIT: for single-column view, that is

[–] attn_dfct_dev 4 points 1 year ago
  • scoop - closest to apt on Windows
  • yt-dlp - active fork of youtube-dl
  • neofetch - System information display
  • winfetch - Same as neofetch, but for windows
  • pandoc - Ultimate converter
  • ffmpeg - must have tool
  • taskwarrior - best task manager imho
[–] FiveAcres 4 points 1 year ago (1 children)

In Bash, I like to use cdargs

sudo apt-get install cdargs

It allows you to set up shortcuts on the fly,

cv sdbackup

rather than cd /media/user/Backup Plus/ MyFiles/current/sdbackup

cv with no argument will give you a list to select from current shortcuts

[–] [email protected] 1 points 1 year ago

Of those mentioned, this one intrigues me most. Thanks!

[–] RandomDevOpsDude 3 points 1 year ago* (last edited 1 year ago)

I write a lot of bash scripts that end up running in automation in some fashion.

#!/usr/bin/env bash

set -euxo pipefail

Is pretty standard for me.

-e exit on error

-o pipefail exit on pipeline fail

-u error on unset variables

-x trace

[–] cd_slash_rmrf 3 points 1 year ago (1 children)

if you spend a lot of time in the shell, i like using the following for easier directory traversal:

  • fzf and its shell bindings for fuzzy-matching arguments
  • z for jumping to "frecent" directories
  • zsh-z (a native zsh port of z)
  • bd for going back directories

and some zsh settings which make cd silently act like pushd/popd:

# autopushd         : make cd act like pushd (alias doesn't work properly)
# pushdminus        : use -1 instead of +1
# pushdsilent       : prevents printing stack on each cd
# pushdtohome       : `pushd` to ~/
# pushdignoredups   : dont add duplicates to stack
[–] gamma 2 points 1 year ago (1 children)

I want to add setopt autocd, and hash -d name=/some/long/path/to/name to create your own ~name shortcuts.

[–] cd_slash_rmrf 2 points 1 year ago

woa, i didn't even know about hash -d name=/path, neat!

[–] fallenpixel 3 points 1 year ago (3 children)

Always partial to yq and jq. No easier way to interact with kubernetes outputs on the fly.

[–] Andy 2 points 1 year ago

I don't know about k8s work in particular, but I enjoy jello and yamlpath more than jq and yq.

[–] RandomDevOpsDude 2 points 1 year ago

How I have never heard of yq, I'm unsure, but thank you as I'm sure it will make life easier

[–] nevalem 2 points 1 year ago

Don't forget about fq!