Skip to main content

credit.sh

0 likes • Oct 26, 2021 • 0 views
Shell
Loading...

More Shell Posts

watchLogins.sh

0 likes • Sep 30, 2021 • 0 views
Shell
touch /tmp/login1.txt /tmp/login2.txt
while [ true ]
do
who | gawk '{ print $1 }' > /tmp/login2.txt
comm -13 /tmp/login1.txt /tmp/login2.txt
#Just a bit easier to read
#diff /tmp/login1.txt /tmp/login2.txt
cat /tmp/login2.txt > /tmp/login1.txt
sleep 1
done

Outputs list of $PATH dirs sorted by line length

0 likes • Nov 18, 2022 • 0 views
Shell
echo -e ${PATH//:/\\n} | awk '{print length, $0}' | sort -n | cut -f2- -d' '

installVulkan.sh

0 likes • Nov 8, 2021 • 0 views
Shell
#!/bin/bash
#Installs the Vulkan library and other goodies. Works on Arch and Arch based distros. Needs pacman and makepkg
installVulkan(){
#Tries installing every linux package in existence
packages=( vulkan-tools libvulkan-dev vulkan-loader-devel vulkan-validation-layers spirv-tools mesa-vulkan-devel vulkan-validation-layers-devel )
for package in ${packages[*]}; do
sudo pacman --noconfirm -S $package
done
}
installLibraries(){
#All of these packages don't exist, so we have to download and install the AUR packages
#packages=( libglfw3-dev glfw-devel libglm glm-devel )
#for package in ${packages[*]}; do
# sudo pacman --noconfirm -S $package
#done
sudo git clone https://aur.archlinux.org/glfw-git.git /tmp/glfw-git
sudo chmod 777 /tmp/glfw-git
cd /tmp/glfw-git
makepkg -si
sudo git clone https://aur.archlinux.org/glm-git.git /tmp/glm-git
sudo chmod 777 /tmp/glm-git
cd /tmp/glm-git
makepkg -si
}
installShaderCompiler(){
#Basically installs glslc
sudo pacman -S shaderc
}
while true; do
select bruh in installVulkan installLibraries installShaderCompiler "exit"; do
$bruh
done
done

Check For File

CHS
0 likes • Aug 7, 2023 • 2 views
Shell
# Three ways of checking if a file exists in a shell script
FILE=/etc/resolv.conf
if test -f "$FILE"; then
echo "$FILE exists."
fi
if [ -f "$FILE" ]; then
echo "$FILE exists."
fi
if [[ -f "$FILE" ]]; then
echo "$FILE exists."
fi

Update Prefixed Dependencies

CHS
0 likes • Oct 9, 2023 • 29 views
Shell
# Update all npm packages under the scope defined by the PREFIX variable ("foo").
PREFIX="foo"; npm ls | grep "$PREFIX" | awk -F/ '{print $NF}' | sed 's/@.*//' | xargs -I package npm update @"$PREFIX"/package

makefileMaker.sh

0 likes • Mar 7, 2021 • 1 view
Shell
#!/bin/bash
#makefileMaker.sh by Leif Messinger
#Needs getDependencies.sh
CC="gcc"
#I have no idea why it's called CXX when it's a c++ compiler
#I know that cpp is c pre processor, but still, why X?
CXX="g++"
CXXFLAGS="-std=c++17 -O2"
#CFLAGS="-std=c17"
LIBRARIES="$@"
#Vulkan Flags for me
#LIBRARIES="-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi"
function compileAllFiles(){
#output: bruh.o yeet.o
# CXX $CXXFLAGS bruh.o yeet.o -o output $LIBRARIES
echo -n "output:"
if compgen -G "*.cpp" &> /dev/null; then
for f in *.cpp; do
echo -n " ${f%.cpp}.o"
done
fi
if compgen -G "*.c" &> /dev/null; then
for f in *.c; do
echo -n " ${f%.c}.o"
done
fi
echo ""
if compgen -G "*.cpp" &> /dev/null; then
echo -e -n "\t$CXX $CXXFLAGS "
else
echo -e -n "\t$CC $CFLAGS "
fi
if compgen -G "*.cpp" &> /dev/null; then
for f in *.cpp; do
echo -n " ${f%.cpp}.o"
done
fi
if compgen -G "*.c" &> /dev/null; then
for f in *.c; do
echo -n " ${f%.c}.o"
done
fi
echo " -o output $LIBRARIES"
echo ""
}
function compileAllObjectFiles(){
#bruh.o: bruh.cpp yeet.h
# CXX $CXXFLAGS -c bruh.cpp $LIBRARIES
if compgen -G "*.cpp" &> /dev/null; then
for f in *.cpp; do
echo -n "${f%.cpp}.o: $f"
getDependencies.sh < $f
echo ""
echo -e "\t$CXX $CXXFLAGS -c $f"
echo ""
done
fi
#yeet.o: yeet.c
# CC $CFLAGS -c yeet.c $LIBRARIES
if compgen -G "*.c" &> /dev/null; then
for f in *.c; do
echo -n "${f%.c}.o: $f"
getDependencies.sh < $f
echo ""
echo -e "\t$CC $CFLAGS -c $f"
echo ""
done
fi
}
compileAllFiles
compileAllObjectFiles
#does not work on windows
echo "clean:"
echo -e "\trm -f -v *.o output"
echo ""
echo "run:"
echo -e "\t./output"
echo ""
echo "debug:"
if compgen -G "*.cpp" &> /dev/null; then
echo -e -n "\t$CXX $CXXFLAGS -g "
else
echo -e -n "\t$CC $CFLAGS -g "
fi
if compgen -G "*.cpp" &> /dev/null; then
for f in *.cpp; do
echo -n " ${f}"
done
fi
if compgen -G "*.c" &> /dev/null; then
for f in *.c; do
echo -n " ${f}"
done
fi
echo " $LIBRARIES -o output"
echo ""