Files
Files: safe operations, search, disk, archives, history.
File aliases/files.sh. Disable: export ALIASX_DISABLE="files"
Safe operations
| Name | Runs | What it does | |
|---|---|---|---|
cpi | cp -i | copy, ask before overwriting | |
mvi | mv -i | move, ask before overwriting | |
rmi | rm -i | remove, ask for each file | |
lni | ln -i | link, ask before overwriting | |
md | mkdir -p | make directory with parents | |
rd | rmdir | remove empty directory | |
backup FILE | copy to FILE.bak.YYYYmmdd-HHMMSSexample$ backup nginx.conf
nginx.conf.bak created | ||
extract ARCHIVE | unpack by extensionexample$ extract release.tar.gz
(files unpacked into current folder) |
Everyday
| Name | Runs | What it does | |
|---|---|---|---|
cx | chmod +x | make executable | |
tailf | tail -f | follow a file | |
cl DIR | cd into DIR and list itexample$ cl src
api/ web/ main.go go.mod | ||
tmpd | create a temp directory and enter itexample$ tmpd
/tmp/tmp.Xk3p9QzL | ||
newest [N] | N most recently modified entries (default 10)example$ newest 3
notes.md
main.go
go.mod | ||
perms FILE | octal permissionsexample$ perms .env
600 .env | ||
dl URL | download into current directory (keeps remote name)example$ dl https://example.com/tool.tar.gz
% Total % Received ... 100 4.1M | ||
tgz DIR | pack DIR into DIR.tar.gzexample$ tgz project
project.tar.gz | ||
zipd DIR | pack DIR into DIR.zipexample$ zipd project
project.zip |
Edit text
| Name | Runs | What it does | |
|---|---|---|---|
prepend FILE [TEXT] | add TEXT (or stdin) as first line(s) of FILEexample$ 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 FILEexample$ append .gitignore node_modules
(last line of .gitignore is now node_modules) |
Search
| Name | Runs | What it does | |
|---|---|---|---|
grep | grep --color=auto | grep with colors | |
egrep | grep -E --color=auto | extended regex grep | |
fgrep | grep -F --color=auto | fixed-string grep | |
countfiles | find . -type f | wc -l | count files below here | |
countdirs | find . -type d | wc -l | count folders below here | |
emptydirs | find . -type d -empty | find empty folders | |
emptyfiles | find . -type f -empty | find empty files | |
ff PATTERN | find files whose name contains PATTERNexample$ ff config
./app/config.yaml
./docs/config.md | ||
ftext TEXT | find 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 PATTERN | find directories whose name contains PATTERNexample$ fdir test
./tests
./api/testdata |
Disk
| Name | Runs | What it does | |
|---|---|---|---|
dfh | df -h | disk free, human sizes | |
dfi | df -i | inode usage | |
usage | du -sh . | size of current folder | |
biggest | 20 biggest files and folders hereexample$ biggest
2.1G ./node_modules
812.0M ./data | ||
du1 | du -h -d 1 | size of each subfolder | macOS |
du1 | du -h --max-depth=1 | size of each subfolder | Linux |
Calculate and hash
| Name | Runs | What it does | |
|---|---|---|---|
calc | bc -l | calculator | |
sha256file FILE | SHA-256 checksum on Linux or macOSexample$ sha256file app.tar.gz
3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b app.tar.gz |
History
| Name | Runs | What it does | |
|---|---|---|---|
h | history | shell history | |
hgrep PATTERN | search shell historyexample$ hgrep docker
412 docker compose up -d
418 docker logs api |