1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00
thefuck/install.sh

58 lines
1.3 KiB
Bash
Raw Normal View History

2015-08-24 18:25:03 +01:00
#!/bin/sh
2015-08-25 10:03:42 +01:00
should_add_alias () {
[ -f $1 ] && ! grep -q thefuck $1
}
2015-09-05 09:54:59 +01:00
installed () {
hash $1 2>/dev/null
}
2015-08-24 18:25:03 +01:00
# Install os dependencies:
2015-09-05 09:54:59 +01:00
if installed apt-get; then
# Debian/ubuntu:
sudo apt-get update -yy
sudo apt-get install -yy python-pip python-dev command-not-found
if [[ -n $(apt-cache search python-commandnotfound) ]]; then
# In case of different python versions:
sudo apt-get install -yy python-commandnotfound
fi
2015-08-24 18:25:03 +01:00
else
2015-09-05 09:54:59 +01:00
if installed brew; then
# OS X:
2015-08-25 10:03:42 +01:00
brew update
2015-08-24 18:25:03 +01:00
brew install python
else
# Genreic way:
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
rm get-pip.py
2015-08-24 18:25:03 +01:00
fi
fi
# thefuck requires fresh versions of setuptools and pip:
sudo pip install -U pip setuptools
sudo pip install -U thefuck
# Setup aliases:
2015-08-25 10:03:42 +01:00
if should_add_alias ~/.bashrc; then
2015-08-24 18:25:03 +01:00
echo 'eval $(thefuck --alias)' >> ~/.bashrc
fi
2015-08-25 10:03:42 +01:00
if should_add_alias ~/.bash_profile; then
2015-08-24 18:25:03 +01:00
echo 'eval $(thefuck --alias)' >> ~/.bash_profile
fi
2015-08-25 10:03:42 +01:00
if should_add_alias ~/.zshrc; then
2015-08-24 18:25:03 +01:00
echo 'eval $(thefuck --alias)' >> ~/.zshrc
fi
2015-08-25 10:03:42 +01:00
if should_add_alias ~/.config/fish/config.fish; then
2015-08-24 18:25:03 +01:00
thefuck --alias >> ~/.config/fish/config.fish
fi
2015-08-25 10:03:42 +01:00
if should_add_alias ~/.tcshrc; then
2015-08-24 18:25:03 +01:00
echo 'eval `thefuck --alias`' >> ~/.tcshrc
fi