diff --git a/install.sh b/install.sh index bd61b74..3d102f3 100755 --- a/install.sh +++ b/install.sh @@ -9,6 +9,12 @@ DOTFILES=( plan ) +CPP_PROGS=( + filteruntil +) + +CXX="${CXX:-g++}" + echo "Setting up oh-my-zsh" rm -rf ~/.oh-my-zsh git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh @@ -25,6 +31,12 @@ do ln -sf $TARGET $LINK done +for f in ${CPP_PROGS} +do + echo "Installing $f" + $CXX -std=c++23 -O3 "$(pwd)/src/$f.cpp" -o "$HOME/bin/$f" +done + mkdir -p ~/bin for f in bin/* do diff --git a/src/filteruntil.cpp b/src/filteruntil.cpp new file mode 100644 index 0000000..3473061 --- /dev/null +++ b/src/filteruntil.cpp @@ -0,0 +1,21 @@ +#include + +int main(int argc, char **argv) { + if(argc != 2) { + std::cerr << "usage: " << argv[0] << " " << std::endl; + return 1; + } + + std::string pattern(argv[1]); + std::string line; + + while(std::getline(std::cin, line)) { + if(line.find(pattern) != std::string::npos) { + break; + } + } + + while(std::getline(std::cin, line)) { + std::cout << line << std::endl; + } +}