• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "cli". Back to normal view
    1. Share your personal dotfile treats and Unix tool recommendations

      I am currently preparing for a new job and cleaning up my dotfile repository. During the process, I had the idea that it would be nice to create a list of amazing tools, aliases, functions, and...

      I am currently preparing for a new job and cleaning up my dotfile repository. During the process, I had the idea that it would be nice to create a list of amazing tools, aliases, functions, and recommendations together.

      I will start.

      First, here is a list of nice tools to apt-get install or brew install that I can wholeheartedly recommend:

      • nvim is just an amazing text editor.
      • fzf is a very good fuzzy finder util. For example, you can quickly find files with it.
      • eza is a good ls replacement (and the successor of exa).
      • bat is a great replacement for cat with nice integrations and many options.
      • stow is great for managing your dotfiles. Thanks to @TangibleLight for telling me about it some while ago. I really love it.
      • tmux is a terminal multiplexer, i.e. you can have many sessions in one single terminal window. It's easy to use and super helpful. (When on a mac, I prefer iTerm tabs, though.)
      • nvm is practically a must if you are working with Node.
      • glow is an excellent markdown reader.
      • tldr is a nice man replacement. (You must run tldr -u after installing it to update available texts.)
      • z, an amazing tool for switching directories quickly.

      Also, I can recommend Oh My ZSH! which I have been using for years.

      Here is a small list of aliases I enjoy (I have 100+ aliases and I tried to pick some others may enjoy as well):

      # Serve current dir
      alias serve="npx serve ."
      
      # What's my IP?
      alias ip="curl --silent --compressed --max-time 5 --url 'https://ipinfo.io/ip' && echo ''"
      
      # This should be the default
      alias mkdir="mkdir -p"
      
      # Nice git helpers
      alias amend="git add . && git commit --amend --no-edit"
      alias nuke="git clean -df && git reset --hard"
      
      # Make which more powerful
      which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
      
      # This saves so many keystrokes, honestly
      alias -- +x="chmod +x"
      
      # Turns your path into a nice list and prints it
      alias path='echo -e ${PATH//:/\\n}'
      
      # Map over arguments and run a command
      # Usage: map <command>
      # Example: ls | map cat
      alias map="xargs -n1"
      

      And, finally, here are some fun functions:

      # Get cheat sheets for almost anything!
      # https://github.com/chubin/cheat.sh
      cheat() {
          WITH_PLUS=$(echo $@ | sed 's/ /+/g')
          CAT_TOOL=$(command -v batcat || command -v bat || command -v cat)
          curl "cheat.sh/$WITH_PLUS" | $CAT_TOOL
      }
      
      # Send everything to /dev/null
      nullify() {
        "$@" >/dev/null 2>&1
      }
      
      # Create a new dir and enter it
      mk() {
        mkdir -p "$@" && cd "$_"
      }
      
      # Create a data URL from a file
      # Source: https://github.com/mathiasbynens/dotfiles/blob/master/.functions
      data-url() {
      	local mimeType=$(file -b --mime-type "$1");
      	if [[ $mimeType == text/* ]]; then
      		mimeType="${mimeType};charset=utf-8";
      	fi
      	echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
      }
      
      74 votes
    2. What are some great time savers on CLI that you would recommend?

      I use these right now on Debian: ncdu ncdu (NCurses Disk Usage): A disk usage analyzer with an ncurses interface, providing a fast and easy-to-use overview of disk space utilization. Ideal for...

      I use these right now on Debian:

      ncdu

      ncdu (NCurses Disk Usage): A disk usage analyzer with an ncurses interface, providing a fast and easy-to-use overview of disk space utilization. Ideal for identifying large directories and files in a user-friendly terminal interface.

      duf

      duf (Disk Usage/Free): A modern disk usage/free utility with a beautiful interface written in Go. It provides a quick and easy way to check disk usage across various file systems with color-coded output.

      tldr

      tldr (Too Long; Didn't Read): Simplified and community-driven man pages. Provides practical examples for commands, making it easier to understand and use without wading through lengthy and detailed man pages.

      nala

      nala (Next-Generation APT Frontend): A modern frontend for the APT package manager, designed to provide a more readable and user-friendly output for package management tasks.

      Speedtest-cli

      Speedtest-cli: A command-line interface for testing internet bandwidth using speedtest.net. Allows you to quickly check your upload and download speeds directly from the terminal.

      htop

      htop: An interactive process viewer for Unix systems. It provides a real-time, color-coded display of system processes, making it easier to monitor and manage system resources.

      powertop

      powertop: A tool for diagnosing issues with power consumption and power management on Linux systems. It provides detailed information on power usage by various system components and applications.

      thinkfan

      thinkfan: A simple fan control program for ThinkPads. It helps manage the system's fan speed to balance cooling and noise levels based on the temperature sensors.

      tlp

      tlp (Linux Advanced Power Management): A power management tool for Linux. It provides various configurations and options to optimize battery life on laptops without requiring manual tweaks.

      flatpak

      Flatpak: A system for building, distributing, and running sandboxed desktop applications on Linux. It provides a universal app distribution system that works across various Linux distributions.

      neofetch

      Neofetch: A command-line system information tool written in bash. It displays an aesthetically pleasing summary of system information alongside your terminal prompt.

      iftop

      iftop: A real-time console-based network bandwidth monitoring tool. It shows a list of network connections from/to your system and the bandwidth usage for each connection.

      nano

      nano: A simple, user-friendly text editor for the command line. Known for its straightforward and easy-to-use interface, making it a go-to for quick text editing tasks.

      Edit
      Oh wow! Thank you all for your suggestions!

      I was looking around and found cheat; it's defined as a cheat that allows you to create and view interactive cheatsheets on the command line. Hopefully, someone else might find it helpful as well.

      38 votes
    3. Linux Question: I think my sys m.2 is failing and want to copy my / data for backup via cli

      So, I'm using Arch i3wm. I have multiple copies of my /home/username (I am the sole user), and I have a "Spare" drive with media, games, and other goodies, some of which are also stored on...

      So, I'm using Arch i3wm. I have multiple copies of my /home/username (I am the sole user), and I have a "Spare" drive with media, games, and other goodies, some of which are also stored on partitions on the m.2 in question, but they have backups.

      And the reason I ask this question is because while I've had my m.2 fail at the end of '21 (I didn't even know that was a thing, but it barely lasted a year, and things are acting shoddy now... though the original failed without a warning), I just bought a second m.2 for my games. I guess I could swap most of the whole thing over, but I know the boot partition is easier just rebuilt from scratch... which I had to do last week.

      Ultimately, what's making me suspicious is when I upgraded to the new drive and unplugged all my non-m.2 satas, I also added some memory and a new power supply. But then after the upgrade (Monday of last week, so the 5th), the system wouldn't boot up. I used a usb to troubleshoot and my /boot partition was apparently no gouda. I redid that, and everything was fine... until this week. Then my new Games partition (basically the new drive) failed fsck and it got stuck in a boot loop on Tuesday. I could boot emergency to root, but not skip the fsck and keep the Games disk auto mounted (I know I changed something to randomize fsck on bootup, but that's something I'm still kinda looking into how I managed...), so I just removed it from my fstab and it booted fine. For two times. I just manually mounted the drive, all was great, then my SO sent me a screenshot today while I was at work stating that my / partition (on the older m.2) apparently rebooted because it bypassed my screen lock, and was stating EXT4-fs error, reading directory lblock:0 and whatnot.

      So, that's my history on what's going on, and if anyone can offer any advice [mostly] on the backup stuff, though as I said, /home and the important tangible stuff is saved, but if you also have any input on something more than I suspect the drive is failing (since the /boot partition and now the / partition are crapping out), please feel free to share.

      (Also, thanks for letting me in. This is what I'd typically post on reddit and probably have to repost 10 times depending on the sub to get the right keywords and tags and yes, I already searched the internet but my search will not match yours... sigh)

      6 votes
    4. Do generic CLI to GUI wrappers exist?

      So I've been messing around with the webp encoder cli tool and I really wish I could quickly achieve a workflow more similar to photoshop's previews. Is there a GUI tool out there where I can...

      So I've been messing around with the webp encoder cli tool and I really wish I could quickly achieve a workflow more similar to photoshop's previews. Is there a GUI tool out there where I can specify the arguments for an CLI executable then it lets me adjust the values and run the command. Ideally it would automatically let me view the output file, and define presets would be great.

      10 votes
    5. Share your useful shell scripts!

      Disclaimer: Don't run scripts offered to you by randos unless you trust them or review it yourself I use this constantly, it just plays music by file name, specifically matching *NAME* with...

      Disclaimer: Don't run scripts offered to you by randos unless you trust them or review it yourself

      I use this constantly, it just plays music by file name, specifically matching *NAME* with case-insensitivity. Requires bash 4.something.

      # play -ln SONGS ...
      # -l don't shuffle
      # -n dry run
      mpv_args="--no-audio-display --no-resume-playback \
                --msg-level=all=status --term-osd-bar"
      shopt -s globstar nullglob nocaseglob
      
      shuffle=true
      dry=false
      while [[ "$1" == -* ]]; do
          if [[ "$1" == "-l" ]]; then 
              shuffle=false
          elif [[ "$1" == "-n" ]]; then
              dry=true
          fi
      
          shift 1
      done
      
      if [[ "$shuffle" == true ]]; then
          mpv_args="--shuffle $mpv_args"
      fi
      
      songs=()
      while [[ "$#" != 0 ]]; do
          songs+=( ~/music/**/**/*"$1"*.* ) # change this to match your music directory layout
          shift 1                                               # could probably use find instead
      done
      
      if [[ "$dry" == true ]]; then
          if [[ "$shuffle" == true ]]; then
              printf "Shuffle mode is on\n"
          fi
      
          for song in "${songs[@]}"; do
              printf "$song\n"
          done
        
          exit
      fi
      
      if [[ ${#songs[@]} != 0 ]]; then
          mpv $mpv_args "${songs[@]}"
      fi
      

      I make no claims to the quality of this but it works!

      36 votes