Last active
October 22, 2015 12:05
-
-
Save derixithy/86f4d715e9cf3341e9d1 to your computer and use it in GitHub Desktop.
Bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Do not remove permanently | |
function rm { | |
mv $1 ~/.Trash # Probably needs a check if dir exists | |
} | |
# grep bash history | |
function grash() { | |
grep --color $1 ~/.bash_history | |
} | |
BIN_DEPS="id $READLINK ls basename ls pwd cut" | |
#Dependencies check | |
for i in $BIN_DEPS; do | |
which $i > /dev/null | |
if [ $? -ne 0 ]; then | |
echo -e "Error: Required program could not be found: $i" | |
exit 1 | |
fi | |
done | |
pause() { | |
local dummy | |
read -s -r -p "Press any key to continue..." -n 1 dummy | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# List permissions in folder | |
ls -l | |
# List permissions of folder | |
ls -ld | |
# Copy permissions from file to file | |
function transferRights() { | |
USAGE="$0 <source> <destination>" | |
if [ "$#" -ne 2 ]; then | |
echo "$USAGE" | |
else | |
chmod --reference=$1 $2 | |
fi | |
} | |
function chmodFiles() { | |
USAGE="$0 <source> <permissions>" | |
if [ "$#" -ne 2 ]; then | |
echo "$USAGE" | |
else | |
find $1 -type f -iname "*" -print0 | xargs -I {} -0 chmod $2 {} | |
fi | |
} | |
function chmodFolders() { | |
USAGE="$0 <source> <permissions>" | |
if [ "$#" -ne 2 ]; then | |
echo "$USAGE" | |
else | |
find $1 -type d -iname "*" -print0 | xargs -I {} -0 chmod $2 {} | |
fi | |
} | |
#To be continued..... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function pomodoro { | |
local worktime="${1:-25m}" pausetime="${2:-3m}" beepcount="${3:-3}" | |
local breakmsg="${4:-'Yout need to take a break!'}" | |
local startmsg="${5:-'Get set, ready? Go!!'}" | |
case "$1" in | |
'stop|quit') | |
rm /tmp/pomodoro.bash.lock | |
;; | |
'help|-h|--help') | |
echo "usage: $0 <worktime:$worktime> <pausetime:$pausetime>" | |
;; | |
*) | |
touch /tmp/pomodoro.bash.lock && trap 'rm /tmp/pomodoro.bash.lock && exit' EXIT | |
while [[ -f /tmp/pomodoro.bash.lock ]] | |
do | |
notify-send "$startmsg" | |
sleep $worktime | |
if [[ -f /tmp/pomodoro.bash.lock ]] | |
then # still running | |
notify-send "$breakmsg" | |
for count in $beepcount | |
do | |
echo -en "\007" | |
sleep 1s | |
done | |
sleep $pausetime | |
fi | |
done | |
;; | |
esac | |
} | |
pomodoro $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
alias reload='source ~/.bash_profile' | |
function edit_bash() { | |
vim ~/.bash_profile | |
reload | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run script in bash without saving | |
wget -qO - "$1" | bash | |
# Print routing table | |
netstat -nr inet | |
# Get Ubuntu release name | |
lsb_release -sc | |
# Exit script on error | |
set -e | |
# Bash version | |
bash --version | |
# Shellshock test | |
env x='() { :;}; echo vulnerable' bash -c "echo this is a test" | |
# Colorfull text wrapper - Handy in scripts | |
printf '\033]2;%s\033\\' "$1" | |
# Track dependancies | |
ldd $1 | |
# Generate passwords | |
apg -a 0 -t -s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment