mirror of https://github.com/curusarn/resh
parent
105886e372
commit
4b5913f611
@ -1,17 +0,0 @@ |
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. |
||||
|
||||
|
||||
[[projects]] |
||||
digest = "1:9f3b30d9f8e0d7040f729b82dcbc8f0dead820a133b3147ce355fc451f32d761" |
||||
name = "github.com/BurntSushi/toml" |
||||
packages = ["."] |
||||
pruneopts = "UT" |
||||
revision = "3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005" |
||||
version = "v0.3.1" |
||||
|
||||
[solve-meta] |
||||
analyzer-name = "dep" |
||||
analyzer-version = 1 |
||||
input-imports = ["github.com/BurntSushi/toml"] |
||||
solver-name = "gps-cdcl" |
||||
solver-version = 1 |
||||
@ -1,34 +0,0 @@ |
||||
# Gopkg.toml example |
||||
# |
||||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html |
||||
# for detailed Gopkg.toml documentation. |
||||
# |
||||
# required = ["github.com/user/thing/cmd/thing"] |
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] |
||||
# |
||||
# [[constraint]] |
||||
# name = "github.com/user/project" |
||||
# version = "1.0.0" |
||||
# |
||||
# [[constraint]] |
||||
# name = "github.com/user/project2" |
||||
# branch = "dev" |
||||
# source = "github.com/myfork/project2" |
||||
# |
||||
# [[override]] |
||||
# name = "github.com/x/y" |
||||
# version = "2.4.0" |
||||
# |
||||
# [prune] |
||||
# non-go = false |
||||
# go-tests = true |
||||
# unused-packages = true |
||||
|
||||
|
||||
[[constraint]] |
||||
name = "github.com/BurntSushi/toml" |
||||
version = "0.3.1" |
||||
|
||||
[prune] |
||||
go-tests = true |
||||
unused-packages = true |
||||
@ -0,0 +1,179 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
set -euo pipefail |
||||
|
||||
die() { |
||||
if [ $# -eq 1 ]; then |
||||
echo "$1" |
||||
elif [ $# -eq 0 ]; then |
||||
echo "ERROR: SomEtHiNg WeNt wRonG - ExItiNg!" |
||||
echo "THIS IS NOT SUPPOSED TO HAPPEN!" |
||||
fi |
||||
echo |
||||
echo "Please report any issues you encounter to: https://github.com/curusarn/resh/issues" |
||||
echo |
||||
echo "You can rerun this installation by executing: (you will skip downloading the files)" |
||||
echo "cd $PWD && scripts/install.sh" |
||||
exit 1 |
||||
} |
||||
|
||||
echo "Checking your system ..." |
||||
|
||||
# /usr/bin/zsh -> zsh |
||||
login_shell=$(echo "$SHELL" | rev | cut -d'/' -f1 | rev) |
||||
|
||||
if [ "$login_shell" != bash ] && [ "$login_shell" != zsh ]; then |
||||
die "ERROR: Unsupported/unknown login shell: $login_shell" |
||||
fi |
||||
echo "Login shell: $login_shell - OK" |
||||
|
||||
|
||||
# check like we are not running bash |
||||
bash_version=$(bash -c 'echo ${BASH_VERSION}') |
||||
bash_version_major=$(bash -c 'echo ${BASH_VERSINFO[0]}') |
||||
bash_version_minor=$(bash -c 'echo ${BASH_VERSINFO[1]}') |
||||
bash_too_old="" |
||||
if [ "$bash_version_major" -lt 3 ]; then |
||||
bash_too_old=true |
||||
elif [ "$bash_version_major" -eq 4 ] && [ "$bash_version_minor" -lt 3 ]; then |
||||
bash_too_old=true |
||||
fi |
||||
|
||||
if [ "$bash_too_old" = true ]; then |
||||
echo "Bash version: $bash_version - UNSUPPORTED!" |
||||
if [ "$login_shell" = bash ]; then |
||||
echo " > Your bash version is old." |
||||
echo " > Bash is also your login shell." |
||||
echo " > Updating to bash 4.3+ is strongly RECOMMENDED!" |
||||
else |
||||
echo " > Your bash version is old" |
||||
echo " > Bash is not your login shell so it should not be an issue." |
||||
echo " > Updating to bash 4.3+ is recommended." |
||||
fi |
||||
else |
||||
echo "Bash version: $bash_version - OK" |
||||
fi |
||||
|
||||
|
||||
if ! zsh --version &>/dev/null; then |
||||
echo "Zsh version: ? - not installed!" |
||||
else |
||||
zsh_version=$(zsh -c 'echo ${ZSH_VERSION}') |
||||
zsh_version_major=$(echo "$zsh_version" | cut -d'.' -f1) |
||||
if [ "$zsh_version_major" -lt 5 ]; then |
||||
echo "Zsh version: $zsh_version - UNSUPPORTED!" |
||||
if [ "$login_shell" = zsh ]; then |
||||
echo " > Your zsh version is old." |
||||
echo " > Zsh is also your login shell." |
||||
echo " > Updating to Zsh 5.0+ is strongly RECOMMENDED!" |
||||
else |
||||
echo " > Your zsh version is old" |
||||
echo " > Zsh is not your login shell so it should not be an issue." |
||||
echo " > Updating to zsh 5.0+ is recommended." |
||||
fi |
||||
else |
||||
echo "Zsh version: $zsh_version - OK" |
||||
fi |
||||
fi |
||||
|
||||
echo |
||||
echo "INSTALLATION" |
||||
exit 0 |
||||
# INSTALLATION |
||||
|
||||
mkdir_if_not_exists() { |
||||
if [ ! -d "$1" ]; then |
||||
mkdir "$1" |
||||
fi |
||||
} |
||||
|
||||
mkdir_if_not_exists ~/.resh |
||||
mkdir_if_not_exists ~/.resh/bin |
||||
mkdir_if_not_exists ~/.resh/bash_completion.d |
||||
mkdir_if_not_exists ~/.resh/zsh_completion.d |
||||
mkdir_if_not_exists ~/.config |
||||
|
||||
echo "Copying files ..." |
||||
cp -f submodules/bash-preexec/bash-preexec.sh ~/.bash-preexec.sh |
||||
cp -f submodules/bash-zsh-compat-widgets/bindfunc.sh ~/.resh/bindfunc.sh |
||||
|
||||
cp -f conf/config.toml ~/.config/resh.toml |
||||
|
||||
cp -f scripts/shellrc.sh ~/.resh/shellrc |
||||
cp -f scripts/reshctl.sh scripts/widgets.sh scripts/hooks.sh scripts/util.sh ~/.resh/ |
||||
|
||||
echo "Generating completions for reshctl ..." |
||||
bin/resh-control completion bash > ~/.resh/bash_completion.d/_reshctl |
||||
bin/resh-control completion zsh > ~/.resh/zsh_completion.d/_reshctl |
||||
|
||||
echo "Copying more files ..." |
||||
cp -f scripts/uuid.sh ~/.resh/bin/resh-uuid |
||||
cp -f bin/* ~/.resh/bin/ |
||||
cp -f scripts/resh-evaluate-plot.py ~/.resh/bin/ |
||||
cp -fr data/sanitizer ~/.resh/sanitizer_data |
||||
|
||||
# backward compatibility: We have a new location for resh history file |
||||
[ ! -f ~/.resh/history.json ] || mv ~/.resh/history.json ~/.resh_history.json |
||||
|
||||
# Adding resh shellrc to .bashrc ... |
||||
grep -q '[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' ~/.bashrc ||\ |
||||
echo -e '\n[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' >> ~/.bashrc |
||||
# Adding bash-preexec to .bashrc ... |
||||
grep -q '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' ~/.bashrc ||\ |
||||
echo -e '\n[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc |
||||
# Adding resh shellrc to .zshrc ... |
||||
grep -q '[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' ~/.zshrc ||\ |
||||
echo -e '\n[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' >> ~/.zshrc |
||||
|
||||
# Deleting zsh completion cache - for future use |
||||
# [ ! -e ~/.zcompdump ] || rm ~/.zcompdump |
||||
|
||||
# Final touch |
||||
touch ~/.resh_history.json |
||||
|
||||
# Restarting resh daemon ... |
||||
if [ -f ~/.resh/resh.pid ]; then |
||||
kill -SIGTERM "$(cat ~/.resh/resh.pid)" |
||||
rm ~/.resh/resh.pid |
||||
else |
||||
pkill -SIGTERM "resh-daemon" || true |
||||
fi |
||||
nohup resh-daemon &>/dev/null & disown |
||||
|
||||
# Generating resh-uuid ... |
||||
[ -e "$(HOME)/.resh/resh-uuid" ] \ |
||||
|| cat /proc/sys/kernel/random/uuid > "$(HOME)/.resh/resh-uuid" 2>/dev/null \ |
||||
|| ./uuid.sh > "$(HOME)/.resh/resh-uuid" 2>/dev/null |
||||
|
||||
echo "\ |
||||
|
||||
########################################################## |
||||
# # |
||||
# SUCCESS - thank you for trying out this project! # |
||||
# # |
||||
########################################################## |
||||
|
||||
WARNING |
||||
It's recommended to RESTART ALL OPEN TERMINAL WINDOWS (or reload your rc files) |
||||
|
||||
HISTORY |
||||
Your resh history will be recorded to '~/.resh_history.json' |
||||
You can look at it using e.g. 'tail -f ~/.resh_history.json | jq' (you might need to install jq) |
||||
|
||||
SANITIZATION |
||||
History can be sanitized by running '... to be included' |
||||
This will create sanitized version of your history |
||||
|
||||
GRAPHS |
||||
You can get some graphs of your history by running '... to be included' |
||||
|
||||
ISSUES |
||||
Please report issues to: https://github.com/curusarn/resh/issues |
||||
|
||||
UNINSTALL |
||||
You can uninstall this at any time by running 'rm -rf ~/.resh/' |
||||
You won't lose any collected history by removing '~/.resh/' directory |
||||
|
||||
Please give me some contact info using this form: https://forms.gle/227SoyJ5c2iteKt98 |
||||
|
||||
" |
||||
@ -1,141 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
set -o pipefail |
||||
|
||||
resh_git_dir=~/.resh_git |
||||
|
||||
if ! go version &>/dev/null; then |
||||
echo |
||||
echo "===========================================================================" |
||||
echo |
||||
echo "Please INSTALL GOLANG" |
||||
echo "after that rerun this script: \`cd $resh_git_dir && make autoinstall\`" |
||||
echo |
||||
if [ "$(uname)" = "Darwin" ]; then |
||||
echo 'You can probably use `brew install go`.' |
||||
echo |
||||
echo "===========================================================================" |
||||
echo |
||||
exit 1 |
||||
elif [ "$(uname)" = "Linux" ]; then |
||||
. /etc/os-release |
||||
if [ "${ID}" = "ubuntu" ]; then |
||||
echo 'You can probably use `sudo snap install go --classic` (gets latest golang - RECOMMENDED)' |
||||
echo 'OR `sudo apt install golang` (this might give you old golang)' |
||||
echo |
||||
echo "===========================================================================" |
||||
echo |
||||
exit 1 |
||||
elif [ "${ID_LIKE}" = "debian" ]; then |
||||
echo 'You can probably use `sudo apt install go`' |
||||
echo |
||||
echo "===========================================================================" |
||||
echo |
||||
exit 1 |
||||
fi |
||||
fi |
||||
echo "It's recomended to use your favourite package manager." |
||||
echo |
||||
echo "===========================================================================" |
||||
echo |
||||
exit 1 |
||||
fi |
||||
|
||||
go_version=$(go version | cut -d' ' -f3) |
||||
go_version_major=$(echo "${go_version:2}" | cut -d'.' -f1) |
||||
go_version_minor=$(echo "${go_version:2}" | cut -d'.' -f2) |
||||
|
||||
if [ "$go_version_major" -gt 1 ]; then |
||||
# good to go - future proof ;) |
||||
echo "Building & installing ..." |
||||
make install |
||||
elif [ "$go_version_major" -eq 1 ] && [ "$go_version_minor" -ge 11 ]; then |
||||
# good to go - we have go modules |
||||
echo "Building & installing ..." |
||||
make install |
||||
else |
||||
echo |
||||
echo "===========================================================================" |
||||
echo "Your Golang version is older than 1.11 - we can't use go modules for build!" |
||||
echo "It's RECOMMENDED to update your Golang! (press Ctrl+C and update Golang manually)" |
||||
echo "after that rerun this script: \`cd $resh_git_dir && make autoinstall\`" |
||||
echo |
||||
|
||||
if [ "$(uname)" = "Linux" ]; then |
||||
. /etc/os-release |
||||
if [ "${ID}" = "ubuntu" ]; then |
||||
echo 'You can probably use `sudo snap install go --classic` to get latest Golang.' |
||||
echo 'It may also be necessary to run `sudo apt remove golang; sudo apt autoremove`.' |
||||
fi |
||||
fi |
||||
echo |
||||
echo "I will try to build the project using dep. (I will let you review each step.)" |
||||
echo "Continue? (Any key to continue / Ctrl+C to cancel)" |
||||
# shellcheck disable=2162 disable=2034 |
||||
read x |
||||
|
||||
take_care_of_gopath=0 |
||||
if [ -z "${GOPATH+x}" ]; then |
||||
echo |
||||
echo "===========================================================================" |
||||
echo "GOPATH env variable is unset!" |
||||
echo "I will take care of GOPATH. (I will create tmp GOPATH.)" |
||||
echo "Continue? (Any key to continue / Ctrl+C to cancel)" |
||||
# shellcheck disable=2162 disable=2034 |
||||
read x |
||||
|
||||
GOPATH=$(mktemp -d /tmp/gopath-XXX) \ |
||||
&& mkdir "$GOPATH/bin" \ |
||||
&& echo "Created tmp GOPATH: $GOPATH" |
||||
export GOPATH |
||||
take_care_of_gopath=1 |
||||
fi |
||||
|
||||
echo "GOPATH=$GOPATH" |
||||
PATH=$GOPATH/bin:$PATH |
||||
|
||||
if ! dep version &>/dev/null; then |
||||
echo |
||||
echo "===========================================================================" |
||||
echo "It appears that you don't have dep installed!" |
||||
echo "I will install dep. (I will install it from GitHub.)" |
||||
echo "Continue? (Any key to continue / Ctrl+C to cancel)" |
||||
# shellcheck disable=2162 disable=2034 |
||||
read x |
||||
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh |
||||
if [ $? -eq 0 ]; then |
||||
echo "Installed dep." |
||||
else |
||||
echo "Installing dep failed - exiting!" |
||||
exit |
||||
fi |
||||
|
||||
fi |
||||
|
||||
project_path=$GOPATH/src/github.com/curusarn/resh |
||||
mkdir -p "$project_path" &>/dev/null |
||||
if [ "$project_path" != "$PWD" ]; then |
||||
if [ "$take_care_of_gopath" -eq 0 ]; then |
||||
echo |
||||
echo "===========================================================================" |
||||
echo "It seems that current directory is not in the GOPATH!" |
||||
echo "I will copy the project to appropriate GOPATH directory." |
||||
echo "Continue? (Any key to continue / Ctrl+C to cancel)" |
||||
# shellcheck disable=2162 disable=2034 |
||||
read x |
||||
fi |
||||
cp -rf ./* .git* "$project_path" && echo "Copied files to $project_path" |
||||
cd "$project_path" |
||||
fi |
||||
|
||||
echo "Running \`dep ensure\` ..." |
||||
if ! dep ensure; then |
||||
echo "Unexpected ERROR while running \`dep ensure\`!" |
||||
exit 2 |
||||
fi |
||||
echo |
||||
echo "===========================================================================" |
||||
echo "Building & installing ..." |
||||
make install |
||||
fi |
||||
Loading…
Reference in new issue