ncsv installer

This commit is contained in:
Ville Rantanen
2016-11-17 13:06:12 +02:00
parent eb98ff014c
commit 04ccdc2e03
2 changed files with 43 additions and 6 deletions

View File

@@ -16,7 +16,21 @@ To see the help page of each tool, run the ./README script
## Installation
1. `hg clone https://bitbucket.org/MoonQ/tools`
2. `. tools/rc`
1. `mkdir -p ~/lib`
2. `hg clone https://bitbucket.org/MoonQ/tools ~/lib/tools`
3. `. $HOME/lib/tools/rc`
It is best to add the last line in your ~/.bashrc
## Dependencies
Many of the tools use common unix tools. Some extra tools are required. Here are
the installation commands.
```
sudo apt-get install sqlite3 python python-magic python-pip python-gtk2 sc \
gnuplot wget vim rsync curl pv
pip install --use csvkit
```
It is best to add the second line in your .bashrc

29
rc
View File

@@ -18,9 +18,27 @@ function _self_update() {
[[ "$1" = "-u" ]] && {
hg pull -u https://bitbucket.org/MoonQ/tools
} || {
timeout 5 hg pull -u hg pull https://bitbucket.org/MoonQ/tools > /dev/null 2>&1
timeout 10 hg pull -u https://bitbucket.org/MoonQ/tools > /dev/null 2>&1
}
popd > /dev/null
# ncsv update
[[ -d "$TOOLSPATH"/ncsv ]] && {
pushd "$TOOLSPATH"/ncsv > /dev/null
[[ "$1" = "-u" ]] && {
hg pull -u
} || {
timeout 10 hg pull -u > /dev/null 2>&1
}
popd > /dev/null
}
}
function _check_ncsv() {
[[ -d "$TOOLSPATH"/ncsv ]] || {
hg clone https://bitbucket.org/MoonQ/ncsv "$TOOLSPATH"/ncsv
ln -sfT ../ncsv/ncsv.py "$TOOLSPATH"/bin/ncsv
ln -sfT ../ncsv/fast-ncsv "$TOOLSPATH"/bin/fast-ncsv
}
}
function _change_hg_repo() {
@@ -40,9 +58,14 @@ function _change_hg_repo() {
sed -i 's,\s*default\s*=.*moonq.kapsi.fi.*,default = ssh://hg@bitbucket.org/MoonQ/tools,' "$TOOLSPATH"/.hg/hgrc
}
}
# install ncsv if necessary
which ncsv > /dev/null 2>&1 || _check_ncsv > /dev/null 2>&1
unset -f _check_ncsv
[[ "$1" = "-u" ]] && _self_update -u
[[ "$1" = "-u" ]] && {
_self_update -u
unset -f _self_update
}
# Update self weekly,
# if folder writable, if repository, if an interactive terminal, if not updated the last week
[[ -w "$TOOLSPATH" ]] || return