✨ Updated scripts
This commit is contained in:
parent
eef4fdf99c
commit
d0aead5a9c
14 changed files with 386 additions and 99 deletions
3
scripts/alarm
Executable file
3
scripts/alarm
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
sleep $1 && notify-send "Times Up!!" &
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
while [ true ] ; do
|
||||
while true ; do
|
||||
PWRLVL=$(cat /sys/class/power_supply/BAT1/capacity)
|
||||
if [ $PWRLVL -le 15 ] ; then
|
||||
exec notify-send "Battery is at 15%!!";
|
||||
break;
|
||||
if [ "$PWRLVL" -le 15 ] ; then
|
||||
notify-send "Battery is at 15%!!";
|
||||
sleep 300s;
|
||||
else
|
||||
sleep 15s;
|
||||
sleep 60s;
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
323
scripts/bgit
323
scripts/bgit
|
|
@ -8,8 +8,12 @@ txtred=${txtbld}$(tput setaf 1)
|
|||
txtyellow=${txtbld}$(tput setaf 3)
|
||||
txtwhite=${txtbld}$(tput setaf 7)
|
||||
|
||||
# Notes on features to add: Have an option for saving password,
|
||||
# rather than automatically just saving it...
|
||||
# Possibly add feature for gitmoji??
|
||||
|
||||
# Intro Prompt
|
||||
echo "${txtblue}bgit: a handy shell script for automating the standard git process"
|
||||
echo "${txtblue}bgit: a handy shell script for automating simple git inits/commits"
|
||||
|
||||
# Reset output style
|
||||
tput bold & tput setaf 7
|
||||
|
|
@ -19,107 +23,246 @@ numrepos=$(git remote | wc -l)
|
|||
|
||||
# If there are no git repositories in this directory...
|
||||
if [ $numrepos -eq 0 ] ; then
|
||||
echo "${txtred}no git repositories in this directory...exiting bgit${txtwhite}"
|
||||
exit 1
|
||||
fi
|
||||
echo "${txtgreen}no git repository found, executing git init...${txtwhite}"
|
||||
while [ true ]
|
||||
do
|
||||
#Prompts the user if they'd like to initialize repository
|
||||
read -e -r -p "${txtwhite}initialize repository?(y/n): ${txtyellow}" init
|
||||
if [[ $init == "n" || $init = "no" ]]; then
|
||||
echo "${txtred}no git repository initialized...exiting${txtwhite}"
|
||||
break
|
||||
elif [[ $init == "y" || $init == "yes" ]] ; then
|
||||
|
||||
# creates a list of repos and puts them in an array
|
||||
repoarray=($(git remote))
|
||||
# Creates a default README.md
|
||||
echo -e "## A Simple README\n\nSome Text" > README.md
|
||||
# Creates a default .gitignore
|
||||
echo -e "node_modules\n*.env\n*.out\n.gitignore" > .gitignore
|
||||
# Initializes git repository cwd...
|
||||
git init
|
||||
# and adds newly created README.md
|
||||
git add README.md
|
||||
|
||||
# Grabs all new files
|
||||
newfiles=$(git status --short | grep '??' | awk '{print $2}' | tr '\n' ' ')
|
||||
while [ true ];
|
||||
do
|
||||
read -e -r -p "${txtwhite}would you like to change username/password from global defaults?(y/n): ${txtyellow}" changedefaults
|
||||
if [[ $changedefaults == "y" || $changedefaults == "yes" ]] ; then
|
||||
read -e -r -p "${txtwhite}enter your username: ${txtyellow}" uname
|
||||
if [[ -n $uname ]] ; then
|
||||
git config user.name $uname
|
||||
read -e -r -p "${txtwhite}enter your email: ${txtyellow}" uemail
|
||||
if [[ -n $uemail ]] ; then
|
||||
git config user.email $uemail
|
||||
break
|
||||
else
|
||||
echo "${txtblue}no email entered, defaulting to global value${txtwhite}"
|
||||
break
|
||||
fi
|
||||
else
|
||||
echo "${txtblue}no username entered, defaulting to global value${txtwhite}"
|
||||
break
|
||||
fi
|
||||
else
|
||||
echo "${txtblue}defaulting to global username/password${txtwhite}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Grabs all modified files
|
||||
modified=$(git status --short | grep M | awk '{print $2}' | tr '\n' ' ')
|
||||
git config commit.gpgsign false
|
||||
|
||||
# Grabs all deleted files
|
||||
deleted=$(git status --short | grep D | awk '{print $2}' | tr '\n' ' ')
|
||||
read -e -r -p "${txtwhite}include gitmoji?(y/n): ${txtyellow}" gittymoji
|
||||
if [[ $gittymoji == "y" || $gittymoji == "yes" ]] ; then
|
||||
gmoji=":tada:"
|
||||
else
|
||||
gmoji=""
|
||||
fi
|
||||
|
||||
# Reports what is staged for commit
|
||||
# If there is anything to commit...
|
||||
if [[ ! -z $newfiles || ! -z $modified || ! -z $deleted ]] ; then
|
||||
# Let the user know what is staged for commit
|
||||
echo "${txtwhite}The following files are staged for commit:"
|
||||
# Otherwise, if there isn't anything to commit...
|
||||
else
|
||||
# Let the user know that everything is up to date
|
||||
echo "${txtred}everything up-to-date...exiting bgit${txtwhite}"
|
||||
# and exit the program
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Let the user know what is staged for commit
|
||||
if [[ $newfiles ]]; then
|
||||
echo "${txtgreen}ADDED: ${txtgreen}$newfiles"
|
||||
fi
|
||||
if [[ $modified ]]; then
|
||||
echo "${txtblue}MODIFIED: ${txtblue}$modified"
|
||||
fi
|
||||
if [[ $deleted ]]; then
|
||||
echo "${txtred}DELETED: ${txtred}$deleted"
|
||||
fi
|
||||
|
||||
|
||||
while [ true ]
|
||||
do
|
||||
# Prompts user if they'd like to commit the changes
|
||||
read -e -r -p "${txtwhite}commit changes?(y/n): ${txtyellow}" change
|
||||
# If the user chooses to commit the changes...
|
||||
if [[ $change == "y" || $change == "yes" ]] ; then
|
||||
|
||||
# Grabs commit message
|
||||
while [ true ]
|
||||
do
|
||||
# Prompts the user to input their commit message
|
||||
read -e -r -p "${txtwhite}commit message: ${txtyellow}" message
|
||||
cmessage=("$message")
|
||||
# if the user inputted a commit message...
|
||||
if [ -n "$message" ] ; then
|
||||
while [ true ]
|
||||
do
|
||||
read -e -r -p "${txtwhite}commit message: ${txtyellow}" message
|
||||
cmessage=("$message")
|
||||
# capitalizes first letter of commit message
|
||||
cmessage="$(tr '[:lower:]' '[:upper:]' <<< ${cmessage:0:1})${cmessage:1}"
|
||||
# if the user entered a commit message over 50 characters...
|
||||
if [ "${#message}" -ge 51 ] ; then
|
||||
echo "${txtred}commit message is too large!"
|
||||
echo "${txtred}please limit to 50 or less characters${txtwhite}"
|
||||
# if the user inputted a commit message..
|
||||
elif [ -n "$message" ] ; then
|
||||
git commit -m "$gmoji $cmessage"
|
||||
# then break out of the while loop and continue with the commit...
|
||||
break
|
||||
# if the user did NOT input a commit message...
|
||||
# if the user did NOT input a commit message...
|
||||
else
|
||||
# tell the user to do so or to quit
|
||||
echo "${txtred}commit message is empty, please write a commit message"
|
||||
echo "${txtred}or type 'CTRL+C' to quit${txtwhite}"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
while [ true ]
|
||||
do
|
||||
read -e -r -p "${txtwhite}change branch name?(y/n): ${txtyellow}" chbranch
|
||||
if [[ $chbranch == "y" || $chbranch == "yes" ]] ; then
|
||||
read -e -r -p "${txtwhite}branch name?(i.e. 'main'): ${txtyellow}" branch
|
||||
if [ -n "$branch" ] ; then
|
||||
git branch -M $branch
|
||||
break
|
||||
else
|
||||
echo "${txtred}branch name is empty, please enter branch name!${txtwhite}"
|
||||
fi
|
||||
else
|
||||
echo "${txtblue}branch name will be left as master${txtwhite}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
while [ true ]
|
||||
do
|
||||
read -e -r -p "${txtwhite}Please enter remote to add: ${txtyellow}" remote
|
||||
if [[ -n $remote ]] ; then
|
||||
read -e -r -p "${txtwhite}Please enter name of repository: ${txtyellow}" repo
|
||||
tput bold & tput setaf 7
|
||||
if [[ -n $repo ]] ; then
|
||||
git remote add $remote "https://codeberg.org/z3rOR0ne/$repo"
|
||||
git push -u $remote $branch
|
||||
echo "${txtgreen}Git repository created!!${txtwhite}"
|
||||
break
|
||||
else
|
||||
echo "${txtred}Please enter a name for repository!${txtwhite}"
|
||||
fi
|
||||
else
|
||||
# tell the user to do so or to quit
|
||||
echo "${txtred}commit message is empty, please write a commit message"
|
||||
echo "${txtred}or type 'CTRL+C' to quit${txtwhite}"
|
||||
echo "${txtred}Please enter a name for remote!${txtwhite}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Reset output style
|
||||
tput bold & tput setaf 7
|
||||
|
||||
# adds the modified and new files (suppresses message anyways if no files are to be committed)
|
||||
if [[ $newfiles || $modified ]] ; then
|
||||
git config advice.addEmptyPathspec false
|
||||
git add $modified $newfiles ;
|
||||
done
|
||||
break
|
||||
else
|
||||
break
|
||||
fi
|
||||
# commits the user's message (multi-word supported)
|
||||
git commit -m "$cmessage" ;
|
||||
done
|
||||
|
||||
# pushes the commit to each repository
|
||||
for ((i = 0; i < $numrepos; i++)) ; do
|
||||
git push ${repoarray[i]} ;
|
||||
done
|
||||
# Otherwise, if there already is a .git directory...
|
||||
else
|
||||
|
||||
exit 0
|
||||
# If the user chooses to not the commit the changes ...
|
||||
elif [[ $change == "n" || $change == "no" ]] ; then
|
||||
# creates a list of repos and puts them in an array
|
||||
repoarray=($(git remote))
|
||||
# Grabs all new files
|
||||
newfiles=$(git status --short | grep '??' | awk '{print $2}' | tr '\n' ' ')
|
||||
# Grabs all modified files
|
||||
modified=$(git status --short | grep M | awk '{print $2}' | tr '\n' ' ')
|
||||
# Grabs all deleted files
|
||||
deleted=$(git status --short | grep D | awk '{print $2}' | tr '\n' ' ')
|
||||
|
||||
# Reset output style
|
||||
tput bold & tput setaf 7
|
||||
|
||||
# Report the git status
|
||||
git status --short
|
||||
|
||||
# And let the user know no changes were committed
|
||||
echo "${txtred}no changes committed"
|
||||
|
||||
exit 0
|
||||
# If the user chooses to quit...
|
||||
elif [[ $change == "q" || $change == "quit" ]] ; then
|
||||
exit 0
|
||||
# If the user continues to just press enter...
|
||||
# Reports what is staged for commit
|
||||
# If there is anything to commit...
|
||||
if [[ ! -z $newfiles || ! -z $modified || ! -z $deleted ]] ; then
|
||||
# Let the user know what is staged for commit
|
||||
echo "${txtwhite}The following files are staged for commit:"
|
||||
# Otherwise, if there isn't anything to commit...
|
||||
else
|
||||
echo "${txtred}please enter y or n or type 'q' or 'quit' or 'CTRL+C' to quit${txtwhite}"
|
||||
# Let the user know that everything is up to date
|
||||
echo "${txtred}everything up-to-date...exiting bgit${txtwhite}"
|
||||
# and exit the program
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Let the user know what is staged for commit
|
||||
if [[ $newfiles ]]; then
|
||||
echo "${txtgreen}ADDED: ${txtgreen}$newfiles"
|
||||
fi
|
||||
if [[ $modified ]]; then
|
||||
echo "${txtblue}MODIFIED: ${txtblue}$modified"
|
||||
fi
|
||||
if [[ $deleted ]]; then
|
||||
echo "${txtred}DELETED: ${txtred}$deleted"
|
||||
fi
|
||||
|
||||
while [ true ]
|
||||
do
|
||||
# Prompts user if they'd like to commit the changes
|
||||
read -e -r -p "${txtwhite}commit changes?(y/n): ${txtyellow}" change
|
||||
# If the user chooses to commit the changes...
|
||||
if [[ $change == "y" || $change == "yes" ]] ; then
|
||||
# prompt if user wants to specify gitmoji:
|
||||
while [ true ]
|
||||
do
|
||||
read -e -r -p "${txtwhite}add a gitmoji?(y/n): ${txtyellow}" gmojiprompt
|
||||
if [[ $gmojiprompt == "y" || $gmojiprompt == "yes" ]] ; then
|
||||
read -e -r -p "${txtwhite}enter gitmoji: ${txtyellow}" gitmoji
|
||||
gitmoji=":$gitmoji:"
|
||||
break
|
||||
else
|
||||
echo "${txtblue}no gitmoji specified...${txtwhite}"
|
||||
gitmoji=""
|
||||
break
|
||||
fi
|
||||
done
|
||||
# Grabs commit message
|
||||
while [ true ]
|
||||
do
|
||||
# Prompts the user to input their commit message
|
||||
# (does not allow for multiple message commits)
|
||||
read -e -r -p "${txtwhite}commit message: ${txtyellow}" message
|
||||
cmessage=("$message")
|
||||
# capitalizes first character of commit message
|
||||
cmessage="$(tr '[:lower:]' '[:upper:]' <<< ${cmessage:0:1})${cmessage:1}"
|
||||
# if the user entered a commit message over 50 characters...
|
||||
if [ "${#message}" -ge 51 ] ; then
|
||||
echo "${txtred}commit message is too large!"
|
||||
echo "${txtred}please limit to 50 or less characters${txtwhite}"
|
||||
# if the user inputted a commit message..
|
||||
elif [ -n "$message" ] ; then
|
||||
# then break out of the while loop and continue with the commit...
|
||||
break
|
||||
# if the user did NOT input a commit message...
|
||||
else
|
||||
# tell the user to do so or to quit
|
||||
echo "${txtred}commit message is empty, please write a commit message"
|
||||
echo "${txtred}or type 'CTRL+C' to quit${txtwhite}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Reset output style
|
||||
tput bold & tput setaf 7
|
||||
|
||||
# adds the modified and new files
|
||||
# (suppresses message anyways if only deleted files are to be committed)
|
||||
if [[ $newfiles || $modified ]] ; then
|
||||
# also remembers password for 1 hour after last use
|
||||
# (comment out if more security needed, or just use ssh...)
|
||||
echo "${txtgreen}git will remember your password for 1 hour!${txtwhite}"
|
||||
git config credential.helper 'cache --timeout=3600';
|
||||
git config advice.addEmptyPathspec false;
|
||||
git add $modified $newfiles ;
|
||||
fi
|
||||
# commits the user's message (multi-word supported)
|
||||
git commit -m "$gitmoji $cmessage" ;
|
||||
|
||||
# pushes the commit to each repository
|
||||
for ((i = 0; i < $numrepos; i++)) ; do
|
||||
git push ${repoarray[i]} ;
|
||||
done
|
||||
|
||||
echo "${txtblue}bgit script has completed! goodbye!${txtwhite}"
|
||||
exit 0
|
||||
# If the user chooses to not the commit the changes ...
|
||||
elif [[ $change == "n" || $change == "no" ]] ; then
|
||||
|
||||
# Reset output style
|
||||
tput bold & tput setaf 7
|
||||
|
||||
# Report the git status
|
||||
git status --short
|
||||
|
||||
# And let the user know no changes were committed
|
||||
echo "${txtred}no changes committed"
|
||||
|
||||
exit 0
|
||||
# If the user chooses to quit...
|
||||
elif [[ $change == "q" || $change == "quit" ]] ; then
|
||||
exit 0
|
||||
# If the user continues to just press enter...
|
||||
else
|
||||
echo "${txtred}please enter y or n or type 'q' or 'quit' or 'CTRL+C' to quit${txtwhite}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
|
|||
17
scripts/changebrightness
Normal file
17
scripts/changebrightness
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
function send_notification() {
|
||||
brightness=$(printf "%.0f\n" $(brillo -G))
|
||||
dunstify -a "changebrightness" -u low -r 9991 -h int:value:"$brightness" -i "brightness-$1" "Brightness: $brightness%" -t 2000
|
||||
}
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
brillo -A 5 -q
|
||||
send_notification $1
|
||||
;;
|
||||
down)
|
||||
brillo -U 5 -q
|
||||
send_notification $1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -11,6 +11,7 @@ declare -a confedit_list=(
|
|||
"bspwm - $HOME/.config/bspwm/bspwmrc"
|
||||
"sxhkd - $HOME/.config/sxhkd/sxhkdrc"
|
||||
"picom - $HOME/.config/picom/picom.conf"
|
||||
"dunst - $HOME/.config/dunst/dunstrc"
|
||||
"i3 - $HOME/.config/i3/config"
|
||||
"kitty - $HOME/.config/kitty/kitty.conf"
|
||||
"nvim - $HOME/.config/nvim/lua/config.lua"
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ function helpmessage()
|
|||
echo ""
|
||||
echo -e "\e[1mjson/html:\e[0m"
|
||||
echo -e "\e[1mjscurl <url> (no 'https://' necessary)\t\t\t\t\t\t show json page\e[0m"
|
||||
echo -e "\e[1mjscurl -m <url> (no 'https://' necessary)\t\t\t\t\t show html page\e[0m" echo -e "\e[1mjscurl -w <url> <filename> (no 'https://' or '.html' necessary)\t write html file to ~/.recycle-bin\e[0m"
|
||||
echo -e "\e[1mjscurl -m <url> (no 'https://' necessary)\t\t\t\t\t show html page\e[0m"
|
||||
echo -e "\e[1mjscurl -w <url> <filename> (no 'https://' or '.html' necessary)\t write html file to ~/.recycle-bin\e[0m"
|
||||
echo -e "\e[1mjscurl -j <url> <filename> (no 'https://' or '.json' necessary)\t write json file to ~/.recycle-bin\e[0m"
|
||||
echo -e "\e[1mjscurl -h/--help\t\t\t\t\t\t\t\t show help page\e[0m"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
myid=$(id -u)
|
||||
echo "your userid is ${myid}"
|
||||
if [[ $myid -ne 0 && $myid -ne 1000 ]]; then
|
||||
echo "[ERROR] You must run this script as root!"
|
||||
exit 0
|
||||
elif [ $myid -eq 1000 ]; then
|
||||
echo "You are ${USER}!"
|
||||
else
|
||||
echo "You are root!"
|
||||
fi
|
||||
|
|
|
|||
8
scripts/rdir
Executable file
8
scripts/rdir
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# A simple bookmarking alias used in conjunction with sdir and our $HOME/.aliases file to bookmark our current directory to be returned to later using rdir.
|
||||
|
||||
# grabs the current $sdir environment variable
|
||||
source $HOME/.zshrc
|
||||
|
||||
cd $sdir
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
last_line_first_word=$(awk '{w=$1} END{print w}' $HOME/.zshrc)
|
||||
|
||||
if [[ $last_line_first_word == "export" ]] ; then
|
||||
sed -i '$ d' $HOME/.zshrc
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/.recycle-bin" ] ; then
|
||||
doas rm -r "$HOME/.recycle-bin/" && doas reboot
|
||||
else
|
||||
|
|
|
|||
34
scripts/rpipe.sh
Executable file
34
scripts/rpipe.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
# https://www.linuxjournal.com/content/using-named-pipes-fifos-bash
|
||||
|
||||
# To be used in conjunction with wpipe.sh (demonstrating mkfifo, or named pipes)
|
||||
|
||||
pipe=/tmp/testpipe
|
||||
|
||||
if [[ ! -p $pipe ]]; then
|
||||
mkfifo $pipe
|
||||
fi
|
||||
|
||||
while true; do
|
||||
if read line < $pipe; then
|
||||
if [[ "$line" == 'quit' ]]; then
|
||||
break
|
||||
fi
|
||||
echo $line
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Exiting"
|
||||
|
||||
# Example Output:
|
||||
# $ sh rpipe.sh &
|
||||
# [3] 23842
|
||||
# $ sh wpipe.sh
|
||||
# Hello from 23846
|
||||
# $ sh wpipe.sh
|
||||
# Hello from 23847
|
||||
# $ sh wpipe.sh
|
||||
# Hello from 23848
|
||||
# $ sh wpipe.sh quit
|
||||
# Reader exiting
|
||||
20
scripts/sdir
Executable file
20
scripts/sdir
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#/bin/bash
|
||||
|
||||
# A simple bookmarking alias used in conjunction with rdir and our $HOME/.aliases file to bookmark our current directory to be returned to later using rdir.
|
||||
|
||||
# grabs the last line of our .zshrc, and grabs the first word
|
||||
last_line_first_word=$(awk '{w=$1} END{print w}' $HOME/.zshrc)
|
||||
|
||||
# if the last line of our rc file begins with "export"...
|
||||
# remove the last line of our rc file
|
||||
if [[ $last_line_first_word == "export" ]] ; then
|
||||
sed -i '$ d' $HOME/.zshrc
|
||||
fi
|
||||
|
||||
# save our current working directory
|
||||
sdir=$(pwd)
|
||||
|
||||
# and write that directory temporarily into our .zshrc
|
||||
echo 'export sdir='$sdir >> $HOME/.zshrc
|
||||
# immediately source it to use it in this shell session
|
||||
source $HOME/.zshrc
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
last_line_first_word=$(awk '{w=$1} END{print w}' $HOME/.zshrc)
|
||||
|
||||
if [[ $last_line_first_word == "export" ]] ; then
|
||||
sed -i '$ d' $HOME/.zshrc
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/.recycle-bin" ] ; then
|
||||
doas rm -r "$HOME/.recycle-bin/" && doas shutdown -h now
|
||||
else
|
||||
|
|
|
|||
30
scripts/wpipe.sh
Executable file
30
scripts/wpipe.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# https://www.linuxjournal.com/content/using-named-pipes-fifos-bash
|
||||
|
||||
# To be used in conjunction with rpipe.sh (demonstrating mkfifo, or named pipes)
|
||||
|
||||
pipe=/tmp/testpipe
|
||||
|
||||
if [[ ! -p $pipe ]]; then
|
||||
echo "Reader not running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$1" ]]; then
|
||||
echo "$1" > $pipe
|
||||
else
|
||||
echo "Hello from $$" > $pipe
|
||||
fi
|
||||
|
||||
# Example Output:
|
||||
# $ sh rpipe.sh &
|
||||
# [3] 23842
|
||||
# $ sh wpipe.sh
|
||||
# Hello from 23846
|
||||
# $ sh wpipe.sh
|
||||
# Hello from 23847
|
||||
# $ sh wpipe.sh
|
||||
# Hello from 23848
|
||||
# $ sh wpipe.sh quit
|
||||
# Reader exiting
|
||||
14
scripts/zhome.sh
Executable file
14
scripts/zhome.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo '' | xclip && xclip -selection clipboard /dev/null && clear && history -p && hash -r && /usr/bin/rm $HOME/.zsh_history && touch $HOME/.zsh_history
|
||||
|
||||
# grabs the last line of our .zshrc, and grabs the first word
|
||||
last_line_first_word=$(awk '{w=$1} END{print w}' $HOME/.zshrc)
|
||||
|
||||
# if the last line of our rc file begins with "export"...
|
||||
# remove the last line of our rc file
|
||||
if [[ $last_line_first_word == "export" ]] ; then
|
||||
sed -i '$ d' $HOME/.zshrc
|
||||
fi
|
||||
|
||||
# unset sdir
|
||||
Loading…
Add table
Add a link
Reference in a new issue