Files

Files: safe operations, search, disk, archives, history.

File aliases/files.sh. Disable: export ALIASX_DISABLE="files"

Safe operations

NameRunsWhat it does
cpicp -icopy, ask before overwriting
mvimv -imove, ask before overwriting
rmirm -iremove, ask for each file
lniln -ilink, ask before overwriting
mdmkdir -pmake directory with parents
rdrmdirremove empty directory
backup FILEcopy to FILE.bak.YYYYmmdd-HHMMSS
example
$ backup nginx.conf
nginx.conf.bak created
extract ARCHIVEunpack by extension
example
$ extract release.tar.gz
(files unpacked into current folder)

Everyday

NameRunsWhat it does
cxchmod +xmake executable
tailftail -ffollow a file
cl DIRcd into DIR and list it
example
$ cl src
api/  web/  main.go  go.mod
tmpdcreate a temp directory and enter it
example
$ tmpd
/tmp/tmp.Xk3p9QzL
newest [N]N most recently modified entries (default 10)
example
$ newest 3
notes.md
main.go
go.mod
perms FILEoctal permissions
example
$ perms .env
600 .env
dl URLdownload into current directory (keeps remote name)
example
$ dl https://example.com/tool.tar.gz
  % Total    % Received ...  100  4.1M
tgz DIRpack DIR into DIR.tar.gz
example
$ tgz project
project.tar.gz
zipd DIRpack DIR into DIR.zip
example
$ zipd project
project.zip

Edit text

NameRunsWhat it does
prepend FILE [TEXT]add TEXT (or stdin) as first line(s) of FILE
example
$ prepend run.sh '#!/bin/sh'
(first line of run.sh is now #!/bin/sh)
append FILE [TEXT]add TEXT (or stdin) as last line(s) of FILE
example
$ append .gitignore node_modules
(last line of .gitignore is now node_modules)

Search

NameRunsWhat it does
grepgrep --color=autogrep with colors
egrepgrep -E --color=autoextended regex grep
fgrepgrep -F --color=autofixed-string grep
countfilesfind . -type f | wc -lcount files below here
countdirsfind . -type d | wc -lcount folders below here
emptydirsfind . -type d -emptyfind empty folders
emptyfilesfind . -type f -emptyfind empty files
ff PATTERNfind files whose name contains PATTERN
example
$ ff config
./app/config.yaml
./docs/config.md
ftext TEXTfind TEXT in files below here (skips .git, node_modules)
example
$ ftext TODO
./api/user.go:42:// TODO: validate email
./web/app.js:7:// TODO: remove debug
fdir PATTERNfind directories whose name contains PATTERN
example
$ fdir test
./tests
./api/testdata

Disk

NameRunsWhat it does
dfhdf -hdisk free, human sizes
dfidf -iinode usage
usagedu -sh .size of current folder
biggest20 biggest files and folders here
example
$ biggest
   2.1G	./node_modules
 812.0M	./data
du1du -h -d 1size of each subfoldermacOS
du1du -h --max-depth=1size of each subfolderLinux

Calculate and hash

NameRunsWhat it does
calcbc -lcalculator
sha256file FILESHA-256 checksum on Linux or macOS
example
$ sha256file app.tar.gz
3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b  app.tar.gz

History

NameRunsWhat it does
hhistoryshell history
hgrep PATTERNsearch shell history
example
$ hgrep docker
  412  docker compose up -d
  418  docker logs api