-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bash scripts to make life easier
- Loading branch information
Showing
8 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ market/ | |
|
||
wip/ | ||
pycallgraph.png | ||
/config.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
I'm hoping that someone more adept at creating user interfaces will | ||
come along and create a front-end for TD; I'm not an elitist who is | ||
bent on command-line world domination. | ||
|
||
This directory is for collections of "scripts" that are designed to | ||
make it easier to use TD. | ||
|
||
These scripts work by reading a configuration file, "config.sh", to | ||
pass common arguments to several trade commands. | ||
|
||
Copy the "config.sh" file from the scripts directory into your main | ||
tradedangerous folder and edit as needed. | ||
|
||
WINDOWS USERS: Read the <WINDOWS USERS> section before proceeding. | ||
|
||
<THE SCRIPTS>: | ||
|
||
The main magic here is the "config.sh" file, keep that up to date | ||
and it will save you a lot of hassle. | ||
|
||
The scripts use this to pass several of the TD parameters, such as | ||
--cr, for you. You can always override these by adding your own | ||
"--cr 1234" at the end of your command. | ||
|
||
Add the scripts folder to your path and setup the environment | ||
variable "TRADEDIR", and all you have to do is run the scripts | ||
from the prompt: | ||
|
||
|
||
$ tdbuyfrom <place> <item> | ||
Uses the 'buy' sub-command to try and find something near the | ||
station you name first. | ||
e.g tdbuyfrom ibootis gold --ly 30 | ||
|
||
|
||
$ tdimad | ||
Downloads and imports data from maddavo | ||
e.g. tdimad | ||
|
||
|
||
$ tdnav <from> <to> | ||
Calculates a route from the first place to the second using your | ||
current "EMPTYLY" value. | ||
e.g tdnav ibootis halai | ||
|
||
|
||
$ tdrun <place> | ||
Calculate a trade run from <place> using the stored values for | ||
cr, cap, ly, empty and jumps. | ||
e.g tdrun ibootis | ||
You can override any of these by supplying them, | ||
e.g. tdrun ibootis --ly 10 | ||
|
||
$ tdupd <station> | ||
Brings up the "update UI" for the specified station | ||
e.g tdupd iboo/beag | ||
|
||
|
||
|
||
<WINDOWS USERS>: | ||
For Windows users, you'll need "bash" from the msysgit package. You | ||
can download it here: http://msysgit.github.io/ | ||
|
||
Once it's installed, press the Windows key and type: git | ||
|
||
The first option you're prompted with should be "git bash". | ||
|
||
When you run it, you should see something like a CMD window but the | ||
prompt is a "$" instead of "C:\WINDOWS\>". This is a bash shell. | ||
|
||
"Bash" uses Linux-style drive/directory name conventions, so you're | ||
C:\Users\MyName\TradeDangerous | ||
would become | ||
/c/users/myname/tradedangerous | ||
|
||
Figure out the bash-path to your trade and then type: | ||
|
||
$ ls /c/users/myname/tradedangerous/trade.py | ||
|
||
to confirm that is indeed where your trade.py is. | ||
|
||
In the likely case that you only use bash for TD, I recommend a few | ||
minor settings tweaks. To change bash settings, type: | ||
|
||
$ start notepad ~/.bashrc | ||
|
||
("~" means "my home directory", ".bashrc" is the config file) | ||
|
||
|
||
Go to the end of the file, add a couple of blank lines and then add | ||
the following lines: | ||
|
||
HISTSIZE=5000 | ||
HISTFILESIZE=10000 | ||
shopt -s histappend | ||
|
||
### CHANGE THIS TO YOUR TradeDangerous path | ||
### (Just don't include the 'trade.py' part | ||
export TRADEDIR="/c/users/myname/tradedangerous" | ||
|
||
# Add the scripts folder to the bash path | ||
export PATH="${TRADEDIR}/scripts:${PATH}" | ||
|
||
# Start all bash sessions from the trade dir | ||
cd "${TRADEDIR}" | ||
|
||
|
||
Edit the "TRADEDIR" path to point to the folder containing trade.py | ||
|
||
Save and quit notepad and type "exit" in the bash shell you have | ||
open to end that bash session, and then open a new onew. | ||
|
||
$ ./trade.py | ||
|
||
and confirm trade.py gives you its help text so all is good. | ||
|
||
Unlike the windows Command prompt, bash will now remember your | ||
command history across sessions. | ||
|
||
Your shell is now also configured to treat the scripts in the | ||
"scripts" folder of TD as commands so you can invoke them by | ||
name. | ||
|
||
OK - Now you can go back and read about the scripts :) | ||
|
||
If you get an error | ||
sh.exe": tdnav: command not found | ||
|
||
Type the following from a prompt: | ||
|
||
$ chmod a+x scripts/td* | ||
|
||
</WINDOWS-USERS> | ||
|
||
|
||
-Oliver | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
### TradeDangerous script configuration | ||
# This file is just a bash script that sets several standard variables. | ||
# It is loaded by the various 'tdxxx' scripts. | ||
|
||
# How to launch trade dangerous | ||
TRADEPY="${TRADEDIR:-.}/trade.py" | ||
|
||
### COMMANDER/SHIP CONFIGURATION | ||
# | ||
|
||
# Put your name here for absolutely no reason at all, *yet* | ||
CMDR="YourName" | ||
|
||
# Current credit balance | ||
CR=270742 | ||
|
||
# You can only have one set of variables "live" at a time, comment out | ||
# old ships while you are not flying them, then you can just uncomment | ||
# them later on. | ||
|
||
# Tweaked Hauler | ||
CAP=20 | ||
EMPTYLY=16.53 | ||
MAXLY=9.23 | ||
JUMPS=6 | ||
|
||
|
||
# Crappy Sidewinder | ||
#CAP=4 | ||
#MAXLY=9.02 | ||
#EMPTYLY=10.04 | ||
#JUMPS=4 | ||
#CR=10203 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /usr/bin/env bash | ||
# Usage: tdbuyfrom <station> <item> [... trade.py options] | ||
# | ||
# Finds stations near <station> that are selling <item> | ||
|
||
. "${TRADEDIR:-.}/config.sh" | ||
|
||
near="$1"; shift | ||
prod="$1"; shift | ||
if [[ | ||
-z $near || $near == -* || | ||
-z $prod || $prod == -* | ||
]] | ||
then | ||
echo "ERROR: Usage: $0 <near> <item> ..." | ||
exit 1 | ||
fi | ||
|
||
cmd="\"${TRADEPY}\" buy --near $near $prod $*" | ||
echo \$ $cmd | ||
eval "$cmd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#! /usr/bin/env bash | ||
# Usage: tdimad [... trade.py options] | ||
# | ||
# Downloads and imports data from maddavo | ||
|
||
. "${TRADEDIR:-.}/config.sh" | ||
|
||
cmd="\"${TRADEPY}\" import -i --maddavo $*" | ||
echo \$ $cmd | ||
eval "$cmd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#! /usr/bin/env bash | ||
# Usage: tdnav <from> <to> [... trade.py options] | ||
# | ||
# Finds a route from one place to another. | ||
|
||
. "${TRADEDIR:-.}/config.sh" | ||
|
||
cmd="\"${TRADEPY}\" nav --ly ${EMPTYLY} $*" | ||
echo \$ $cmd | ||
eval "$cmd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#! /usr/bin/env bash | ||
# Usage: tdrun [... trade.py options] | ||
# | ||
# Calculates a trade run from <place> using trade.py | ||
|
||
|
||
. "${TRADEDIR:-.}/config.sh" | ||
|
||
origin="$1"; shift | ||
if [[ | ||
-z $origin || $origin == -* | ||
]] | ||
then | ||
echo "ERROR: Usage: $0 <origin> ..." | ||
exit 1 | ||
fi | ||
|
||
cmd="\"${TRADEPY}\" run -vv \ | ||
--ly ${MAXLY} \ | ||
--empty ${EMPTYLY} \ | ||
--cap ${CAP} \ | ||
--jumps ${JUMPS} \ | ||
--cr ${CR} \ | ||
--from \"${origin}\" \ | ||
$@" | ||
echo \$ $cmd | ||
eval "$cmd" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
# Usage: tdupd <station> [... trade.py options] | ||
# | ||
# Edits the specified station using the new GUI | ||
|
||
. ${TRADEDIR:-.}/config.sh | ||
|
||
cmd="\"${TRADEPY}\" update -GF $*" | ||
echo \$ $cmd | ||
eval "$cmd" | ||
|