3 ms·
I came up with this alias for xargs, I find it quite handy, # f# like |> pipelining, example `echo "~/.bashrc" |: vim _` # sed here is removing the las
by frfl 3y ago
I came up with this alias for xargs, I find it quite handy,
# f# like |> pipelining, example `echo "~/.bashrc" |: vim _`
# sed here is removing the last newline of the output
alias ::='sed "$ s/\n$//" | xargs -I_ --'
Usage example, where `_` is a marker `::` (xargs) uses to swap in the pipe'd value
sudo docker ps -a | skip 1 | col 1 |:: sudo docker rm _
skip, col are other aliases/functions,
function col {
eval "awk '{ print \$$1 }'"
}
function skip {
tail -n +$(($1 + 1))
}
function take {
head -n $1
}
- frfl 3y ago(cont) I also quite like, function mkcd { command mkdir -p "$1" && \ command cd "$1" && \ pwd } I'm thinking of writing one for git clone, `git clonecd` or something, to cd into a cloned directory. Note that having an executable named `git-foo` in your $PATH lets you call it like a git subcommand, `git foo`