add filteruntil
Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
parent
82c8a6aaa1
commit
1c6cc5bb5e
2 changed files with 33 additions and 0 deletions
12
install.sh
12
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
|
||||
|
|
21
src/filteruntil.cpp
Normal file
21
src/filteruntil.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <iostream>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if(argc != 2) {
|
||||
std::cerr << "usage: " << argv[0] << " <pattern-string>" << 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue