-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_fim.sh
executable file
·60 lines (40 loc) · 1.26 KB
/
setup_fim.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# FIM Setup Script
# This script is intended to configure your local shell to use FIM from the docker image
FIM_DIR=${HOME}/.fim/
FIM_IMAGE="fim:latest"
function confirmation_prompt() {
# https://stackoverflow.com/questions/226703/how-do-i-prompt-for-yes-no-cancel-input-in-a-linux-shell-script/27875395#27875395
RETURN=${1}
shift
MSG="$*"
while true; do
read -p "${MSG}" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) return ;; #exit $RETURN;;
* ) echo "Please answer yes or no.";;
esac
done
}
mkdir -p ${FIM_DIR}
id=$(docker create ${FIM_IMAGE})
docker cp $id:/app/fortune.db ${FIM_DIR}/fortune.db
docker cp $id:/app/fimrc ${FIM_DIR}/fimrc
docker rm -v $id
FIM="alias fim=\"docker run -v ~/.fim/:/var/fim ${FIM_IMAGE} \""
FIM_DEBUG="alias fim_debug=\"docker run -it --entrypoint /bin/bash -v ~/.fim/:/var/fim ${FIM_IMAGE} \""
echo "To utilize this you must mount the directory: ${FIM_DIR} into your container
It is recommended to use th following alias:
${FIM}
"
{
confirmation_prompt 0 "Do you want to add the alias to your .bashrc? "
echo $FIM >> ~/.bashrc
echo $FIM_DEBUG >> ~/.bashrc
}
{
confirmation_prompt 0 "Do you want to add the alias to your .zshrc? "
echo $FIM >> ~/.zshrc
echo $FIM_DEBUG >> ~/.zshrc
}