···11# my-bash-scripts
2233-These are the basic bash scripts I've made for myself. They're made for macOS, so there's no guarantee they'll work on other OSes.
33+These are the basic bash scripts I've made for myself. They're made for macOS, so there's no guarantee they'll work on other OS-es.
4455-# Install
55+## Install
66771. Download the scripts and put them in whatever folder you want. In my case, they are in `~/dev/my-bash-scripts/bin`.
882. Add the folder to your PATH, so you can call the scripts by their filename in your terminal from anywhere. Edit the file named `.bash_profile` (or create it if it does not exist). Add the following line to it: `export PATH=<YOUR_FOLDER>:$PATH`.
991010-1111-# Scripts
1010+## Scripts
12111312## welp
1413Super simple script that lists the files in the same folder as the script is in. In other words, it lists the scripts here.
15141615## chill
1716Stops execution for a specified amount of time. Useful for scheduling stuff. `chill` shows the syntax:
1717+1818```
1919Syntax: chill #h
2020Syntax: chill #m
···30303131## copy
3232Run a command and copy the output to the clipboard. For example, run `copy pwd` to copy the current path.
3333+3334```
3435Usage:
3536 copy <command> [args...]
···37383839## md5compare
3940Compares md5s of two files.
4141+4042```
4143Usage: md5compare <file1> <file2>
4244```
43454446## render
4547This will render [After Effects](https://www.adobe.com/products/aftereffects.html) projects, assuming you have After Effects installed in `/Applications/Adobe After Effects CC 2019` (Specifically, the `aerender` file needs to be in there). Running `render` shows the syntax:
4848+4649```
4750Usage:
4851 render [options] <file> [file...]
4949-5252+5053Options:
5154 file .aep file for After Effects' aerender to render.
5255 -h, --help Show this help text
···5861Resets permissions of a directory. You should probably know what you're doing before running this.
59626063Running `reset-permissions` shows the syntax:
6464+6165```
6266reset-permissions
6367usage: reset-permissions <username> <directory>
6468```
65696670This is the command it will run:
7171+6772```
6873sudo chmod -RN <DIRECTORY> && \
6974sudo chown -R <USERNAME> <DIRECTORY> && \
···7378## sleepy
7479Hibernates your computer. I usually run this after `render` or `chill`.
75808181+## sfx
8282+8383+```
8484+sfx:
8585+ Play a sound effect. Example: sfx ding.
8686+8787+Usage:
8888+ sfx <sound>
8989+9090+Sounds:
9191+ ding beep
9292+```
9393+7694## to-gif
7795Requires [ffmpeg](https://ffmpeg.org) (which I recommend installing using [Homebrew](https://brew.sh)).
78967997Converts videos into gifs. If you do this frequently I would probably use some app instead.
80988199Running `to-gif` shows the syntax:
100100+82101```
83102Syntax: to-gif <file> [fps] [scale] [duration] [start_at]
84103 file: File to convert to gif. Required.
+39
bin/sfx
···11+#! /bin/bash
22+33+color() {
44+ echo -n "`tput setaf $1`${@:2}"
55+ # reset color if there are arguments:
66+ if [[ "$#" > 1 ]]; then echo -n "`tput sgr0`"; fi
77+}
88+red() { color 1 "$@"; }
99+green() { color 2 "$@"; }
1010+yellow() { color 3 "$@"; }
1111+cyan() { color 6 "$@"; }
1212+reset() { color 7 "$@"; echo -n `tput sgr0`; }
1313+1414+ARG1="$1"
1515+1616+SCRIPT_PATH="${BASH_SOURCE[0]}"
1717+BIN_PATH="`dirname "$SCRIPT_PATH"`"
1818+TOP_PATH="`dirname "$BIN_PATH"`"
1919+SOUNDS_PATH="$TOP_PATH/sounds"
2020+2121+if [[ $ARG1 == 'ding' ]]; then
2222+ afplay "$SOUNDS_PATH/Ding.mp3"
2323+elif [[ $ARG1 == 'beep' ]]; then
2424+ afplay "$SOUNDS_PATH/Beep.mp3"
2525+else
2626+ FILENAME=${0##*/}
2727+ echo ""
2828+ echo "`green $FILENAME:`"
2929+ echo " Play a sound effect. Example: `yellow $FILENAME ding`."
3030+ echo ""
3131+ echo "`green Usage:`"
3232+ echo " $FILENAME <sound>"
3333+ echo ""
3434+ echo "`green Sounds:`"
3535+ echo " ding beep"
3636+ echo ""
3737+# Example: copy pwd"
3838+3939+fi