It's often useful to apply a command to each line of STDIN inside a pipeline.
This is easy to do in fish
:
ls | while read line; echo $line; end
It's often useful to apply a command to each line of STDIN inside a pipeline.
This is easy to do in fish
:
ls | while read line; echo $line; end
To get the SHA256 hash of an existing public key, simply run
ssh-keygen -lvf path/to/key.pub
If you want the MD5 hash (or another supported format), run something like
ssh-keygen -lv -E MD5 -f path/to/key.pub
You can quickly visualize your current git tree structure with
git log --graph --oneline --all
If you have a folder my/folder
, you can run
du -h my/folder | sort -rh | head -n 10
to get a list of the 10 largest subfolders.
Explanation:
du -h
: get the size of the elements in the folder in human-readable formatsort -rh
: sort human-readable in reverse order (requires an updated version of sort
)head -n 10
: only take the first 10 elementsWe can use httpie to make requests to the W3C validator.
For example, to test the file index.html
, run
https "https://validator.w3.org/nu/?out=gnu" @index.html "Content-Type: text/html; charset=utf-8" --print 'b'
and any errors or warnings will be printed to STDOUT.
You can also get the error format in JSON by using the out=json
syntax.
Another option which can be done locally is to use the python html5validator.
For example, if all your files are in a directory called html
, calling
This is a short function demonstrating how to run a sequence of commands in parallel and wait for them to be completed before continuing
function test_sleep
set -l pid_list
for i in 1 4 2 5 3
# execute the command and put it in the background
fish --command "
sleep $i
echo \"Finished command $i!\"
" &
Often, it is useful to jump to search for a directory and automatically change to it.
By comining the fd and fzf tools, we can create a simple cd
variant:
function fcd
set --local base "$HOME"
set --local target (fd --base-directory $base --type directory | fzf --query "$argv")
cd $base/$target
end
Call with fcd $query
where $query
is an optional string to initialize the search.