[READ-ONLY] Mirror of https://github.com/probablykasper/my-bash-scripts. My personal bash scripts
cli
0

Configure Feed

Select the types of activity you want to include in your feed.

Added `sfx` script

Kasper (Sep 4, 2020, 6:52 PM +0200) 00640d8c ce92e820

+63 -5
+24 -5
README.md
··· 1 1 # my-bash-scripts 2 2 3 - 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. 3 + 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. 4 4 5 - # Install 5 + ## Install 6 6 7 7 1. Download the scripts and put them in whatever folder you want. In my case, they are in `~/dev/my-bash-scripts/bin`. 8 8 2. 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`. 9 9 10 - 11 - # Scripts 10 + ## Scripts 12 11 13 12 ## welp 14 13 Super simple script that lists the files in the same folder as the script is in. In other words, it lists the scripts here. 15 14 16 15 ## chill 17 16 Stops execution for a specified amount of time. Useful for scheduling stuff. `chill` shows the syntax: 17 + 18 18 ``` 19 19 Syntax: chill #h 20 20 Syntax: chill #m ··· 30 30 31 31 ## copy 32 32 Run a command and copy the output to the clipboard. For example, run `copy pwd` to copy the current path. 33 + 33 34 ``` 34 35 Usage: 35 36 copy <command> [args...] ··· 37 38 38 39 ## md5compare 39 40 Compares md5s of two files. 41 + 40 42 ``` 41 43 Usage: md5compare <file1> <file2> 42 44 ``` 43 45 44 46 ## render 45 47 This 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: 48 + 46 49 ``` 47 50 Usage: 48 51 render [options] <file> [file...] 49 - 52 + 50 53 Options: 51 54 file .aep file for After Effects' aerender to render. 52 55 -h, --help Show this help text ··· 58 61 Resets permissions of a directory. You should probably know what you're doing before running this. 59 62 60 63 Running `reset-permissions` shows the syntax: 64 + 61 65 ``` 62 66 reset-permissions 63 67 usage: reset-permissions <username> <directory> 64 68 ``` 65 69 66 70 This is the command it will run: 71 + 67 72 ``` 68 73 sudo chmod -RN <DIRECTORY> && \ 69 74 sudo chown -R <USERNAME> <DIRECTORY> && \ ··· 73 78 ## sleepy 74 79 Hibernates your computer. I usually run this after `render` or `chill`. 75 80 81 + ## sfx 82 + 83 + ``` 84 + sfx: 85 + Play a sound effect. Example: sfx ding. 86 + 87 + Usage: 88 + sfx <sound> 89 + 90 + Sounds: 91 + ding beep 92 + ``` 93 + 76 94 ## to-gif 77 95 Requires [ffmpeg](https://ffmpeg.org) (which I recommend installing using [Homebrew](https://brew.sh)). 78 96 79 97 Converts videos into gifs. If you do this frequently I would probably use some app instead. 80 98 81 99 Running `to-gif` shows the syntax: 100 + 82 101 ``` 83 102 Syntax: to-gif <file> [fps] [scale] [duration] [start_at] 84 103 file: File to convert to gif. Required.
+39
bin/sfx
··· 1 + #! /bin/bash 2 + 3 + color() { 4 + echo -n "`tput setaf $1`${@:2}" 5 + # reset color if there are arguments: 6 + if [[ "$#" > 1 ]]; then echo -n "`tput sgr0`"; fi 7 + } 8 + red() { color 1 "$@"; } 9 + green() { color 2 "$@"; } 10 + yellow() { color 3 "$@"; } 11 + cyan() { color 6 "$@"; } 12 + reset() { color 7 "$@"; echo -n `tput sgr0`; } 13 + 14 + ARG1="$1" 15 + 16 + SCRIPT_PATH="${BASH_SOURCE[0]}" 17 + BIN_PATH="`dirname "$SCRIPT_PATH"`" 18 + TOP_PATH="`dirname "$BIN_PATH"`" 19 + SOUNDS_PATH="$TOP_PATH/sounds" 20 + 21 + if [[ $ARG1 == 'ding' ]]; then 22 + afplay "$SOUNDS_PATH/Ding.mp3" 23 + elif [[ $ARG1 == 'beep' ]]; then 24 + afplay "$SOUNDS_PATH/Beep.mp3" 25 + else 26 + FILENAME=${0##*/} 27 + echo "" 28 + echo "`green $FILENAME:`" 29 + echo " Play a sound effect. Example: `yellow $FILENAME ding`." 30 + echo "" 31 + echo "`green Usage:`" 32 + echo " $FILENAME <sound>" 33 + echo "" 34 + echo "`green Sounds:`" 35 + echo " ding beep" 36 + echo "" 37 + # Example: copy pwd" 38 + 39 + fi
sounds/Beep.mp3

This is a binary file and will not be displayed.

sounds/Ding.mp3

This is a binary file and will not be displayed.