Skip to content

Instantly share code, notes, and snippets.

@danielbayley
Last active May 16, 2020 00:30
Show Gist options
  • Save danielbayley/751d2603057851990de93fb3a0a001ea to your computer and use it in GitHub Desktop.
Save danielbayley/751d2603057851990de93fb3a0a001ea to your computer and use it in GitHub Desktop.
Make any command accept stdin.
#! /bin/zsh --no-rcs --err-exit
pushd = cd () { builtin $0 "${@:-`<&0`}"}
pwd # $HOME
print ~/Desktop | cd
pwd # ~/Desktop
cd -
pwd # $HOME
pwd # $HOME
print ~/Desktop | pushd
pwd # ~/Desktop
popd
pwd # $HOME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment