mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
Working on install script(s)
This commit is contained in:
12
scripts/scripts/allfigl
Executable file
12
scripts/scripts/allfigl
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
font_dir="$(brew --prefix)/share/figlet/fonts"
|
||||
|
||||
for font in "${font_dir}"/*.flf; do
|
||||
clear
|
||||
echo "FONT: $font"
|
||||
figlet -f "${font}" hello
|
||||
read -r line
|
||||
done
|
||||
8
scripts/scripts/banner
Executable file
8
scripts/scripts/banner
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
message="${1:-m-housh}"
|
||||
font="${2:-puffy}"
|
||||
|
||||
echo "${message}" | figlet -c -f "${font}"
|
||||
4
scripts/scripts/chmox
Executable file
4
scripts/scripts/chmox
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
# makes files executable
|
||||
test -f "$1" && chmod +x "$1"
|
||||
5
scripts/scripts/clean_screenshots
Executable file
5
scripts/scripts/clean_screenshots
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
for file in "$SCREENSHOTS"/*; do
|
||||
rm "$file"
|
||||
done
|
||||
8
scripts/scripts/cmt
Executable file
8
scripts/scripts/cmt
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# adapted from...
|
||||
# https://github.com/rwxrob/dot/blob/main/scripts/cmt
|
||||
|
||||
while IFS= read -r line; do
|
||||
echo "${1:-#} $line"
|
||||
done
|
||||
17
scripts/scripts/dmg
Executable file
17
scripts/scripts/dmg
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Creates an encrypted disk image from a folder
|
||||
|
||||
set -e
|
||||
|
||||
from="$1"
|
||||
to="$2"
|
||||
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Usage: dmg <fromdir> <todir>"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
name="$(isosec).dmg"
|
||||
hdiutil create -encryption AES-256 -srcfolder "$from" "$to/$name"
|
||||
10
scripts/scripts/dots
Executable file
10
scripts/scripts/dots
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Open dotfiles.
|
||||
|
||||
set -e
|
||||
|
||||
test -d "${DOTFILES}" || \
|
||||
(echo "Dotfiles path not a directory or doesn't exist" && exit 1)
|
||||
|
||||
cd "${DOTFILES}" && vi .
|
||||
5
scripts/scripts/duck
Executable file
5
scripts/scripts/duck
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
url="https://lite.duckduckgo.com/lite?kd=1&kp=1&q=$(urlencode "$*")"
|
||||
|
||||
exec lynx "$url"
|
||||
16
scripts/scripts/figl
Executable file
16
scripts/scripts/figl
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create a new figlet (ascii art) from the input.
|
||||
|
||||
figl() {
|
||||
font=${FIGL_FONT:-puffy}
|
||||
declare -a buf
|
||||
while IFS= read -r line; do
|
||||
buf+=("$line")
|
||||
done
|
||||
for line in "${buf[@]}"; do
|
||||
figlet -f "$font" -c "${line}" | head -6
|
||||
done
|
||||
}
|
||||
|
||||
figl "$*"
|
||||
9
scripts/scripts/isosec
Executable file
9
scripts/scripts/isosec
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
isosec() {
|
||||
echo "$(date -u '+%Y%m%d%H%M%S')"
|
||||
}
|
||||
|
||||
isosec
|
||||
5
scripts/scripts/l
Executable file
5
scripts/scripts/l
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lists files and directories, including hidden files.
|
||||
|
||||
ls -lah --color "$@"
|
||||
58
scripts/scripts/link_apps
Executable file
58
scripts/scripts/link_apps
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Creates symlinks from external application directory
|
||||
# to another directory so applications are seen in
|
||||
# spotlight searches and launchpad.
|
||||
|
||||
set -e
|
||||
|
||||
app_dir=""
|
||||
destination_dir=""
|
||||
|
||||
# Parses the input arguments. If 2 arguments are passed in, then
|
||||
# the first is where we search for applications (source) and the second
|
||||
# argument is the destination directory for the symlinks to be placed in
|
||||
#
|
||||
# If one argument is passed in, then it is used as the destination directory
|
||||
# and we use the default source directory.
|
||||
_parse_args() {
|
||||
arg_count="$#"
|
||||
app_dir="/Volumes/M1 Mac-Mini External Drive/Applications"
|
||||
destination_dir="${HOME}/Application"
|
||||
if test "$arg_count" -eq 1; then
|
||||
destination_dir="$1"
|
||||
elif test "$arg_count" -eq 2; then
|
||||
app_dir="$1"
|
||||
destination_dir="$2"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if the `app_dir` exists.
|
||||
_is_mounted() {
|
||||
if ! test -d "$app_dir"; then
|
||||
echo "Application directory does not exist or is not mounted" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------- main -------------------
|
||||
|
||||
main() {
|
||||
|
||||
_parse_args "$@"
|
||||
test -d "${destination_dir}" || echo "Destination does not exist" >&2
|
||||
|
||||
if test _is_mounted; then
|
||||
for app in "${app_dir}"/*.app; do
|
||||
destination="${destination_dir}/$(basename "${app}")"
|
||||
if test -e "${destination}"; then
|
||||
echo "Destination already exists: ${destination}. Skipping!" >&2
|
||||
continue
|
||||
fi
|
||||
# remove echo to do real work.
|
||||
echo ln -sv "${app}" "${destination}" >&2
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
12
scripts/scripts/mkcd
Executable file
12
scripts/scripts/mkcd
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Createsa directory then `cd`'s into the directory
|
||||
|
||||
set -e
|
||||
|
||||
dir="$1"
|
||||
|
||||
test -n "${dir}" || echo "usage: mkcd <dir>" && exit 1
|
||||
|
||||
mkdir "${dir}"
|
||||
cd "${dir}"
|
||||
26
scripts/scripts/newx
Executable file
26
scripts/scripts/newx
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Creates a new executable file in the $SCRIPTS directory.
|
||||
|
||||
# check if the scripts path / environment variable is set
|
||||
test ! -n "${SCRIPTS}" && echo "SCRIPTS not set" && exit 1;
|
||||
|
||||
# fallback to check if the name arg ${1} exists, if not show usage text.
|
||||
test ! -n "${1}" && \
|
||||
echo "usage: newscript <name> <optional: shell>" && \
|
||||
echo "shell defaults to sh if not supplied" && \
|
||||
exit 1;
|
||||
|
||||
path="${SCRIPTS}/${1}"
|
||||
shell="${2:-sh}"
|
||||
|
||||
if [ -e "${path}" ]; then
|
||||
echo "Already exists try:"
|
||||
echo "vi ${path}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "#!/bin/%s\n\n" "${shell}" > "${path}"
|
||||
chmod +x "${path}"
|
||||
exec vim +2 "${path}"
|
||||
|
||||
2
scripts/scripts/path
Executable file
2
scripts/scripts/path
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/zsh
|
||||
echo -e ${PATH//:/\\n}
|
||||
8
scripts/scripts/uncmt
Executable file
8
scripts/scripts/uncmt
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# adapted from...
|
||||
# https://github.com/rwxrob/dot/blob/main/scripts/ucmt
|
||||
|
||||
while IFS= read -r line; do
|
||||
echo "${line#* }"
|
||||
done
|
||||
34
scripts/scripts/urlencode
Executable file
34
scripts/scripts/urlencode
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# yeah, i totally stole this from stack exchange, no shame
|
||||
|
||||
rawurlencode() {
|
||||
local string="${1}"
|
||||
local strlen=${#string}
|
||||
local encoded=""
|
||||
local pos c o
|
||||
|
||||
for ((pos = 0; pos < strlen; pos++)); do
|
||||
c=${string:$pos:1}
|
||||
case "$c" in
|
||||
[-_.~a-zA-Z0-9]) o="${c}" ;;
|
||||
*) printf -v o '%%%02x' "'$c'" ;;
|
||||
esac
|
||||
encoded+="${o}"
|
||||
done
|
||||
echo "${encoded}" # You can either set a return variable (FASTER)
|
||||
REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
|
||||
}
|
||||
|
||||
if test -n "$1"; then
|
||||
rawurlencode "$*"
|
||||
exit
|
||||
fi
|
||||
|
||||
IFS=
|
||||
while read -r line; do
|
||||
rawurlencode "$line"
|
||||
done
|
||||
5
scripts/scripts/vic
Executable file
5
scripts/scripts/vic
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# opens a shell command in vi
|
||||
cmd=$(command -v $1)
|
||||
test -n "$cmd" && vi "$cmd"
|
||||
Reference in New Issue
Block a user