๐Ÿ’พ Archived View for splint.rs โ€บ little_programs.gmi captured on 2024-08-31 at 12:36:20. Gemini links have been rewritten to link to archived content

View Raw

More Information

โฌ…๏ธ Previous capture (2024-07-09)

-=-=-=-=-=-=-

Small Utilities I Like

Standard Linux

stat

Show file info.


  Size: 5277            Blocks: 16         IO Block: 4096   regular file
Device: 805h/2053d      Inode: 6554954     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   ghost)   Gid: ( 1000/   ghost)
Access: 2022-02-21 20:48:37.840867061 +0100
Modify: 2022-02-21 20:41:44.774001797 +0100
Change: 2022-02-21 20:41:44.778001768 +0100
 Birth: 2022-02-21 20:41:44.774001797 +0100

file

Show what type of file something is.


dbus-U00gxuKxNT:       socket
scoped_dirNCvmsA:      directory
serverauth.ELLhbMvz60: X11 Xauthority data

watch

Watch a command for changes in the output.


Or watch how much of the filesystem is free.


Timeout

Let a command run for a limited amount of time:


Useful if you want a process to automatically run, but itโ€™s in danger of stopped, and asking you some questions. For example, if you want to โ€˜apt updateโ€™, then that might work, but it might stall until you answer a question. You canโ€™t really answer that question if the thing is running as part of a script, so to avoid having it hang, just cancel it after 10 minutes (or some time longer than an upgrade might take).

NB: When using sudo, the timeout command will apply to sudo itself, so best to run after the sudo, e.g.


This may still lock the database, but at least you wonโ€™t have a bunch of useless scripts building up.

New Utilities

cloc

Count the lines of code in a repository.


      48 unique files.
      18 files ignored.

github.com/AlDanial/cloc v 1.92  T=0.05 s (879.2 files/s, 181191.9 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C++                              7            934            255           4916
C/C++ Header                     8            103            106            724
TeX                              7            113             16            660
CSV                              8              0              0            654
Python                           4             59             49            652
Markdown                         3            187              0            220
Bourne Shell                     4             34             14            121
make                             5              0              0             49
YAML                             1              0              0             15
CMake                            1              3              5              3
-------------------------------------------------------------------------------
SUM:                            48           1433            445           8014
-------------------------------------------------------------------------------

This can be useful for an overview of a project. The program is also great at counting actual lines of code, rather than just lines. The following contains 6 lines:

sort -r > list


cat < list

cloc will recognize blank lines are not lines of code, and recognize joined lines of code as separate.

duf

This outputs disk usage with a nice display.


โ”‚ 2 local devices                                                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ MOUNTED ON โ”‚   SIZE โ”‚   USED โ”‚  AVAIL โ”‚  USE%  โ”‚ TYPE โ”‚ FILESYSTEM โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ /          โ”‚ 117.6G โ”‚  63.7G โ”‚  47.8G โ”‚  54.2% โ”‚ ext4 โ”‚ /dev/sda5  โ”‚
โ”‚ /boot/efi  โ”‚ 602.1M โ”‚ 152.0K โ”‚ 602.0M โ”‚   0.0% โ”‚ vfat โ”‚ /dev/sda6  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

notify-send

Output a message to your desktop.


This will output a notification to finish making tea in 8 minutes. The โ€˜disownโ€™ statement tells the terminal to leave the process running, even without the terminal.

fzy

This gives you the ability to type through a list to select an item.

Try this for a start:


โ””โ”€โ–บโ”€๏‘ญ ls | fzy
> 
Distros
LK
Mail
Projects
VMs
arc
dl
gollum
img
kn

Okay - not terribly impressive so far. But we can do things with the output.


Now we can find anywhere in the home directory and change directory there instantly. Or open any nearby file in vim:



Now you can just type in vf and type the name of a file you want to edit, and fzy will find it for you.

onefetch

Output a summary of a Git.

$$            $$$$      $$$     $   -----------------------------------
$  $$  $$  $$$$$  $$$$ $$$   Project: core (3 branches, 6 tags)
$ $$$  $$$ $$$$$  $$$ $$$   HEAD: 115ba07 (dev, origin/dev)
$ $$$  $$          $$  $$ $$$$   Pending: 20+-
$ $$$  $$$  $$$  $$  $ $$$$   Version: 0.6
$$$$  $$$  $$$ $$$  $$$$$   Created: 2 years ago
$$$$  $$$  $$$ $$$  $$$$$   Language: TeX (100.0 %)
$$$$  $$$  $$$$$$   $$$$   Authors: 100% Malin Freeborn 2188
$$$$  $$$  $$ $$$$ $  $$$$            0% Vladar4 1
$$$$  $$$      $$$ $$  $$$   Last change: a week ago
$$$$  $$$  $$ $$$ $$$  $$$   Repo: https://gitlab.com/bindrpg/core
$$$$  $$$  $$$$ $$$$  $$   Commits: 2189
$$$        $  $$$     $$$     $   Lines of code: 8416
$$$$$$$$  $$$$ $$$$$$$$   Size: 11.22 MiB (78 files)
$$$$$$$$  $$$ $$$$$$$$   License: GPL-3.0-only
$$$$$$$           $$$$$$$$
$$$$$$$$$$$$$$$$$$$$