Skip to content

Commit 090e645

Browse files
committed
chore: cleaned up
1 parent 10dc765 commit 090e645

21 files changed

+146
-266
lines changed

.idea/.bash.d.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.gitignore

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

avaiable/00_colours.bash

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ESC_SEQ="\x1b["
2-
COL_RESET=$ESC_SEQ"39;49;00m"
3-
COL_RED=$ESC_SEQ"31;01m"
4-
COL_GREEN=$ESC_SEQ"32;01m"
5-
COL_YELLOW=$ESC_SEQ"33;01m"
6-
COL_BLUE=$ESC_SEQ"34;01m"
7-
COL_MAGENTA=$ESC_SEQ"35;01m"
8-
COL_CYAN=$ESC_SEQ"36;01m"
2+
export COL_RESET=$ESC_SEQ"39;49;00m"
3+
export COL_RED=$ESC_SEQ"31;01m"
4+
export COL_GREEN=$ESC_SEQ"32;01m"
5+
export COL_YELLOW=$ESC_SEQ"33;01m"
6+
export COL_BLUE=$ESC_SEQ"34;01m"
7+
export COL_MAGENTA=$ESC_SEQ"35;01m"
8+
export COL_CYAN=$ESC_SEQ"36;01m"

avaiable/01_path.bash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export PATH=$PATH:$HOME/bin:$HOME/.local/bin:$HOME/.screenlayout:$HOME/opt/Postman
1+
export PATH=$PATH:$HOME/bin
2+
export PATH=$PATH:$HOME/.local/bin
3+
export PATH=$PATH:$HOME/.screenlayout
4+
export PATH=$PATH:$HOME/opt/Postman

avaiable/02_bash_completion.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# anything in $HOME/.local/bash_completion.d ending .bash get included
2-
source $HOME/.local/bash_completion.d/*.bash
2+
source "$HOME/.local/bash_completion.d/*.bash"
33

4-
# other environment specific scriots should not end .bash, e.g. see 87_django.bash
4+
# other environment specific scripts should not end .bash, e.g. see 87_django.bash

avaiable/09_shell_tools.bash

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,89 @@
1-
export PATH=$HOME/usr/lib/Shell-tools:$PATH
2-
31
function countdown() {
4-
start="$(( $(date '+%s') + $1))"
5-
while [ $start -ge $(date +%s) ]; do
6-
time="$(( $start - $(date +%s) ))"
7-
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
8-
sleep 0.1
9-
done
2+
start="$(($(date '+%s') + $1))"
3+
while [ $start -ge "$(date +%s)" ]; do
4+
time="$((start - $(date +%s)))"
5+
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
6+
sleep 0.1
7+
done
108
}
119

1210
function fixperms {
13-
# HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1)
14-
HTTPDUSER=www-data
11+
while getopts "u:h" options; do
12+
case $options in
13+
u) NEW_USER="$OPTARG" ;;
14+
h)
15+
echo "Use setfacl to give a single user +rw/+rwx to a subtree of commands, defaults to current user"
16+
echo "$0 [-u <user_id|user_name] dir1 dir2 ..."
17+
exit
18+
;;
19+
*) echo "unknown option" ;;
20+
esac
21+
done
22+
23+
if [ -z "$NEW_USER" ]; then
24+
NEW_USER=$USER
25+
fi
26+
27+
if [[ -z $1 ]]; then
28+
TARGET=$(pwd)
29+
else
30+
# TODO Fix the shellcheck SC2124
31+
# shellcheck disable=SC2124
32+
TARGET=$@
33+
fi
34+
35+
echo -e "${COL_YELLOW}Fix permission on current directory and all sub directories?${COL_RESET}"
36+
read -p "Are you sure? " -n 1 -r
37+
echo
38+
if [[ $REPLY =~ ^[Yy]$ ]]; then
39+
sudo setfacl -dR -m u:"$NEW_USER":rwX -m u:"$(whoami)":rwX "$TARGET"
40+
sudo setfacl -R -m u:"$NEW_USER":rwX -m u:"$(whoami)":rwX "$TARGET"
41+
fi
42+
}
1543

16-
if [[ -z $1 ]]; then
17-
echo -e "${COL_YELLOW}Fix permission on current directory and all sub directories?${COL_RESET}"
18-
read -p "Are you sure? " -n 1 -r
44+
function randpass {
45+
while getopts "hsx" options; do
46+
case $options in
47+
h)
48+
echo "$(basename "$0") [-s] [-x]"
1949
echo
20-
if [[ $REPLY =~ ^[Yy]$ ]]; then
21-
TARGET=$(pwd)
22-
else
23-
return 0
24-
fi
50+
echo "Generates a random 24 character password. The -s flag restricts the password"
51+
echo "to alphanumeric characters only. The -x will use the XKCD random four word"
52+
echo "password generation (http://xkcd.com/936/)"
53+
;;
54+
x) xkcd=1;;
55+
s) safe=1;;
56+
*) echo "Unknown option";;
57+
esac
58+
done
59+
60+
if [ -z $xkcd ]; then
61+
if [ -z $safe ]; then
62+
pass=$(</dev/urandom tr -dc 'A-Za-z0-9!@#$%&/()=' | head -c24)
2563
else
26-
TARGET="$@"
64+
pass=$(</dev/urandom tr -dc 'A-Za-z0-9' | head -c24)
2765
fi
28-
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX $TARGET
29-
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX $TARGET
66+
else
67+
pass=$( \
68+
grep -v "'" /usr/share/dict/words| \
69+
shuf -n4 | \
70+
sed 's/.*/\L&/g' | \
71+
iconv -f utf8 -t ascii//TRANSLIT \
72+
)
73+
fi
74+
75+
colours="$COL_RED $COL_GREEN $COL_YELLOW $COL_BLUE"
76+
77+
for word in $pass; do
78+
colour=$(echo "$colours" | awk '{print $1}')
79+
echo -en "$colour""$word"
80+
colours=$(echo "$colours" | awk '{$1="";print $0}')
81+
done
82+
echo -e "$COL_RESET"
83+
84+
echo "$pass" | tr -d '\n' | xsel -ib
85+
86+
if [ "$?" ]; then
87+
echo "The password has been pushed to your clipboard, you can paste it where you want it"
88+
fi
3089
}

avaiable/10_java.bash

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=gasp'
2-
export PATH=$PATH:/home/tobias/opt/idea-IU-201.8538.31/bin

avaiable/11_minecraft.bash

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)