mirror of
https://github.com/plexus/chemacs2.git
synced 2026-09-10 07:26:27 -04:00
The only paths you can take for granted are `/bin/sh` and `/usr/bin/env`. Using `/bin/bash` may not work on every system (for example on NixOS). This commit fixes this by using `/bin/sh` instead. Signed-off-by: Guillaume Pagnoux <guillaume.pagnoux@lse.epita.fr>
41 lines
783 B
Bash
Executable file
41 lines
783 B
Bash
Executable file
#!/bin/sh
|
|
|
|
chemacs_path=$(realpath "$(dirname "$0")")
|
|
|
|
main() {
|
|
if [ -L "$HOME/.emacs" ]; then
|
|
check_existing_symlink
|
|
else
|
|
create_symlink_if_possible
|
|
fi
|
|
}
|
|
|
|
check_existing_symlink() {
|
|
target=$(readlink -f "$HOME/.emacs")
|
|
|
|
if [ "$target" != "$chemacs_path/.emacs" ]; then
|
|
warn "~/.emacs symlink points elsewhere -> $target"
|
|
else
|
|
ok "chemacs already linked, you're all good."
|
|
fi
|
|
}
|
|
|
|
create_symlink_if_possible() {
|
|
if [ -e "$HOME/.emacs" ]; then
|
|
warn "chemacs can't be installed, ~/.emacs is in the way"
|
|
else
|
|
ok "Creating symlink ~/.emacs -> $chemacs_path/.emacs"
|
|
ln -s "$chemacs_path/.emacs" "$HOME"
|
|
fi
|
|
}
|
|
|
|
warn() {
|
|
printf "WARN\t%s\n" "$1"
|
|
}
|
|
|
|
ok() {
|
|
printf "OK\t%s\n" "$1"
|
|
}
|
|
|
|
main
|