/r/commandline

Photograph via snooOG

This is for anything regarding the command line, in any operating system. All questions (including dumb ones), tips, and links to interesting programs/console applications you've found or made yourself are welcome. Linux / BSD / OSX / Windows CLI and TUI apps or questions or comments, we're happy to take them all!

  -----------------------------

/ This is for anything
| regarding the command line, | | in any operating system. All | | questions (including dumb | | ones), tips, and interesting | | programs/console applications | | you've found or made yourself | | are welcome. Please read the | | rules, and you're welcome to | | flair your posts if you want |

\ to. /
\   ^__^
 \  (OO)\_______
    (__)\       )\/\
        ||----w |
        ||     ||

commandline@reddit ~ $ _


If you're asking for help, remember to help the community by stating what OS and version you're using, and if at all possible paste any commands you've tried and any errors or output that you've seen.


Related subreddits:

/r/commandline

94,187 Subscribers

10

I'm developing an open source touchable terminal emulator and multiplexer over WebRTC

2 Comments
2024/05/12
13:33 UTC

2

Skill Issues

Hi everyone!

I am Sanzhar, a Computer Science Freshman who is trying to build some fun staff. Yesterday I created and published a npm wrapper that console logs "Skill issues" banner when error occurs. Could you please check this out and leave recommendations or any other thoughts about this little fun project? Can you please recommend any other ideas I have to try to build over this summer?

Install by typing: npm install -g skill-issues

Execute any npm command with Skill Issues, by replacing npm with sis or skill-
issues command.

Links for more information:
https://www.npmjs.com/package/skill-issues
https://github.com/sanxzhar/skill-issues

0 Comments
2024/05/12
13:02 UTC

1

dynamically construct the FFmpeg command to utilize only the desired devices

To dynamically construct an FFmpeg command to utilize only the desired devices, you can follow these general steps:

  1. List available devices: Use a command-line tool or library to list available audio and video devices. For example, on Linux, you can use arecord -l for audio devices and v4l2-ctl --list-devices for video devices.

  2. Parse device information: Write a script or program to parse the output of the device listing commands and extract relevant information such as device IDs, names, and capabilities.

  3. Filter out unused devices: Implement logic to filter out unused devices based on criteria such as device type (audio or video), device capabilities, or user preferences.

  4. Construct FFmpeg command: Based on the filtered device information, dynamically generate the FFmpeg command with the appropriate input options for the selected devices.

Here's a simplified example in Python:

import subprocess

# Function to list audio devices
def list_audio_devices():
    return subprocess.check_output(['arecord', '-l']).decode('utf-8')

# Function to list video devices
def list_video_devices():
    return subprocess.check_output(['v4l2-ctl', '--list-devices']).decode('utf-8')

# Parse device information and filter unused devices
def filter_devices(device_list):
    # Implement your filtering logic here
    # For simplicity, let's assume all devices are used
    return device_list

# Construct FFmpeg command
def construct_ffmpeg_command(audio_devices, video_devices):
    # Replace this with your actual FFmpeg command construction logic
    ffmpeg_command = f'ffmpeg -f alsa -i {audio_devices} -f v4l2 -i {video_devices} output.mp4'
    return ffmpeg_command

# Main function
def main():
    audio_devices = list_audio_devices()
    video_devices = list_video_devices()

    # Filter out unused devices
    filtered_audio_devices = filter_devices(audio_devices)
    filtered_video_devices = filter_devices(video_devices)

    # Construct FFmpeg command
    ffmpeg_cmd = construct_ffmpeg_command(filtered_audio_devices, filtered_video_devices)
    print("Generated FFmpeg command:", ffmpeg_cmd)

if __name__ == "__main__":
    main()

This script provides a basic framework for dynamically constructing an FFmpeg command based on available audio and video devices. You'll need to replace the placeholder logic with actual parsing and filtering code tailored to your specific requirements and environment.

0 Comments
2024/05/12
12:24 UTC

4

Noob question about different shell compatibility for Linux script. If I am writing a script what should I write at the top of the `.sh` file ? If I write `/bin/bash` is that okay ?

Hello. I have a noob question related to running Linux script on different shells. I have written a bash script and in the first I have provided #! /bin/bash for script to be execute using Bash.

But what if someone has some different shell and does not have Bash ? Does the user need to change manually bash into something else ? Is there some way to make the script compatible with multiple different Linux shells ? And is it possible for user not having Bash to run bash script using some other shell ?

7 Comments
2024/05/12
12:03 UTC

3

Why is my last command not working?

**UPDATE**: Problem solved. Limited the use of elevated privileges by only using sudo in the clamscan command and running the script as normal user. Now works perfectly.

I have a bash script that creates a temp file with filenames, it then feeds that list to clamscan for scanning only files that have been modified. I'd like to open the log file with the application "kate" at the end of the script and then exit the existing terminal. It isn't working. The script runs the scan, but then just exits without opening the logfile. The command itself is accurate and works brilliantly if run What am I doing wrong?

#!/usr/bin/bash
# CLAMSCAN RECENTLY CHANGED FILES
# DIRECTORIES TO SCAN
scan_dir="/home/"
# TEMPORARY FILE
list_file=$(mktemp -t clamscan.XXXXXX) || exit 1
# LOCATION OF LOG FILE
log_file="/home/clamweekly.log"
# MAKE LIST OF NEW FILES
if [ -f  "$log_file" ]
then
        # use newer files then logfile
        find "$scan_dir" -type f -cnewer "$log_file" -fprint "$list_file"
else
        # scan modified in last 7 days
        find "$scan_dir" -type f -ctime -7 -fprint "$list_file"
fi

if [ -s "$list_file" ]
then
        # Scan files
        clamscan -i -f "$list_file" > "$log_file"
else
        # remove the empty file, contains no info
        rm -f "$list_file"
fi
# OPEN THE LOG FILE TO REVIEW AND CLOSE THE TERMINAL
kate $log_file & disown
exit
9 Comments
2024/05/12
09:45 UTC

16

CWF - Copy and paste with friends everywhere

Hey fellow CLI nerds :)

cwf or Copy with Friends is a small CLI tool for a collaborative clipboard. You can send and receive content from and to your friends or colleagues.

https://reddit.com/link/1cpvegr/video/hxwkep374wzc1/player

Feel free to check cwf out on Github.

3 Comments
2024/05/12
00:29 UTC

46

ugrep 6.0 released

What's new in 6.0?

  • quicker: ugrep 6.0 is faster than before
  • new goodies: includes ugrep-indexer to index slow FS for faster searching

In a nutshell, ugrep

  • is backward compatible to BSD/GNU grep to make it easier to transition
  • searches (nested!) tar, pax, cpio, zip and 7zip archives and gz, bz, bz2, xz, lz4, lzma, zstd and brotli compressed files
  • searches pdfs, docs, ebooks, image metadata with the ug+ and ugrep+ commands
  • offers a TUI for interactive searching
  • offers Google-like Boolean AND/OR/NOT search queries and options
  • offers fuzzy search options
  • supports Unicode regex patterns by default
  • outputs hexdumps of matching binary files (with option -X)
  • can be configured with personal preferences using a configuration file (generated with --save-config) used by the ug command
  • is one of the fastest grep tools

See ugrep.com for the installation and user guides and the ugrep GitHub project repo

8 Comments
2024/05/11
01:58 UTC

65

play - TUI playground for your favorite programs, such as grep, sed, awk, jq and yq

6 Comments
2024/05/10
18:52 UTC

0

How to install fastfetch on Windows 11?

Basically, I wanted to install fastfetch on a windows 11 desktop but i'm not sure how to do it. Can someone just give me a quick rundown on how to?

2 Comments
2024/05/10
02:35 UTC

4

so-answer-open: CLI app - Open a stackoverflow answer by category and key question phrase using fuzzy search from registered links

6 Comments
2024/05/09
16:55 UTC

3

Global copy registers for bash? Like Vim

I use vim and occasionally neovim.

Is there a function like Register for bash?

I want to copy something specific in a global register and then have it available in another environment.

10 Comments
2024/05/09
12:17 UTC

5

Need help finding out how to understand these codes

I'm taking a Bash tutorial and I'm supposed to figure this out, but don't know what to look for:

ls -d f* q* | tee ls.txt

ls -d f* q* 2>&1 | tee ls.txt

find . -type f | wc -l

The man page doesn't explain things clearly for a beginner, and some stuff I don't find. I haven't even found "-type" on Google.

I'm not asking for the answers, but I would like to be pointed into the right direction. It can be a typed tutorial or video.

Also are there resources that explains the man pages?

42 Comments
2024/05/08
00:09 UTC

1

[Midnight Commander] Don't wait for the external editor to close the file

I set Emacs as my external editor for MC. I run Emacs from my terminal using emacs -nw. I set up an alias in my .bashrc alias mc='EDITOR=emacsclient -nw mc... and it works. I open MC in another terminal, F4 opens the selected file in my already opened Emacs instance. But untill I close the file in Emacs the MC window says waiting... and this is not what I want. Basically I'd like to send a file to Emacs and keep browsing other files in MC maybe send another file etc.

tia

4 Comments
2024/05/07
18:15 UTC

2

Media controls for targeted firefox tab

Does anyone know if it's possible natively to send a command to a specific firefox tab like pause/play any running media?

I would like to setup a keyboard shortcut to pause/resume any tabs that have plex/youtube playing. Even if there's no direct support for pausing, if I could just send a JS snippet to a specific tab I could figure out how to interact with whatever media is in that tab.

4 Comments
2024/05/07
12:46 UTC

5

Resources for learning automation and shell scripting?

First of all, I am sadly a Windows user. I have to use a Windows PC for my job. With that being said, I have managed to install Zsh, NuShell, and PowerShell 7.

My problem is that I don't really know how to truly maximize these tools. I mostly need something to automate tasks like text manipulation, folder and file creation, searching for text, etc.

I used to use Python, but I find it to be overkill for the tasks I need, when I need something very powerful and complex I use it. But if its something like moving x files to y folder I think shell commands do that more efficiently.

I already know the basic commands and can navigate easily any shell. What I need is that specific scripting knowledge for automation. Any suggestions would be greatly appreciated.

10 Comments
2024/05/07
12:32 UTC

0

AWS CMD KungFu !

I have been working on Migrating AWS Lambda functions from the Go1.x runtime to the custom runtime on Amazon Linux 2, Created the sprint script to list lambda func in all region

https://github.com/muhammedabdelkader/Micro-Sprint/blob/main/reports/list_lambda.sh

Don't forgot the filter command

0 Comments
2024/05/07
07:57 UTC

1

Easy Config is a glorified multi-thread shell executor.

Hey o/

I kinda got tired of copy pasting my personal "README" to setup my local machine for development, so I decided to automate the process with a multi-thread approach.

Now it takes less than 2 minutes to have my setup ready to go.

Repo: https://github.com/brenoprata10/easy-config

https://reddit.com/link/1clheak/video/avv24ew5rsyc1/player

5 Comments
2024/05/06
12:06 UTC

7

Is there a shorthand for referencing the first word(usually the command itself) of the previous command?

I've searched around and could only find $^ for referencing the first argument passed to the previous command, analog to the !$ for the last arg. But sometimes I'd like to use the command itself for example after running the command: > some_really_long_program 'arg1' 'arg2' , and then I want to search the man page of the command some_really_long_program.

Without c-p and deleting all the arguments, is there also a shorthand for this case in bash for zsh?

6 Comments
2024/05/06
08:42 UTC

64

I love Zoxide

What is Zoxide

Zoxide is a better ‘cd’ with additional features to help you shortcut some repetitive, tedious tasks.

How does cd work

The command ‘cd’ stands for change directory, which is pretty self-explanatory. Let’s say that you have the current file structure, and the current root folder name, in this case, is called `tutorial`. Now, if we want to navigate to the ‘folder1’ directory, we use the following command.

Then, our terminal will be pointed to `folder1` under `tutorial.` If we wish to go up a folder back to `tutorial,` we run the following command.

The `..` will reference the parent directory. There may be instances where you have to navigate to a folder that is 5 layers deep, and once you get there, you will notice that navigating back to the root folder is not as straightforward. You will have to make a mental note of how many folders deep you are and run something like this.

The command above will point your machine 4 folders up. You can start to see the problem. A similar annoyance arises when you initially want to navigate to your project from a new terminal window. Most of my projects are in a folder called ‘code,’ so every time I want to navigate to a project, I run something like the one below.

Where Zoxide comes in

Doing all these navigation jumps becomes a little repetitive after a while. Wouldn’t it be nice if I could just go straight to the project? Well, that’s what Zoxide is for. Zoxide uses ‘z’ instead of ‘cd’. So instead of typing `cd ./code/supercoolproject` every time, you only have to do it once with ‘z’!

Zoxide will remember where you went! It never gets old, and I use it every time. If the end folder has a similar name to another path you z’d to, it will prompt you to pick!

Will it make me 10x?

No. Some of you may be saying, “This doesn’t save that much time, “and I will say, yeah, you are right. For me, it is not about the time saved but the convenience it brings. I rather type less than I need to do the same thing.

https://ryanspears.substack.com/p/you-should-probably-start-using-zoxide

32 Comments
2024/05/06
06:36 UTC

7

TUI tool for sending packets of arbitrary input and monitoring packets.

https://github.com/ddddddO/packemon

Hi! I have created a TUI tool that allows me to create and send packets of any network layer! Also, it can monitor packets. This tool is still under development.

4 Comments
2024/05/05
19:00 UTC

0

HELP ARIAC2 UNINSTALL? WINDOWS.

Hello, i found this thing "aria2c" using 70gb of my internet, how do i install it? im running windows

2 Comments
2024/05/05
09:49 UTC

2

Custom EZA colors

I'm using eza as a replacement for ls.

I'm looking for a way to set custom colors for some file types (like .odt -> blue, .ods -> green) but I can't find anything helpful.

Is there any way to do it?

Ty!

2 Comments
2024/05/05
08:42 UTC

14

spinner-memory-game-cli - Remember spinners appearences sequence and restore the correspondence of spinners to their appearance numbers

4 Comments
2024/05/04
23:44 UTC

Back To Top