def get_history(self): out, err = self.run_cmd('for val in $history; echo -n $val \\x1e; end') hist_tokens = [tk for tk in out.split(' \x1e') if 'cd' in tk] print(hist_tokens) if hist_tokens: hist_tokens.pop() # remove the command which started all this shit oset = OrderedSet() oset.update(hist_tokens) self.history = oset
def get_history(self): out, err = self.run_cmd('cat ~/.bash_history') hist_tokens = [tk for tk in out.split('\n')[:1000] if 'cd' in tk] pprint.pprint(hist_tokens) if hist_tokens: hist_tokens.pop() oset = OrderedSet() oset.update(hist_tokens) self.history = oset