gko / ssh-connect

🐙 simple ssh manager based on bash/zsh history

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It wont find my previous ssh connections on bash/zsh

piratx opened this issue · comments

commented

Really glad to find this little useful utility for (recent) ssh connections.

I am trying to find out why I get a connect: empty list while I am using it on macos (10.14) with zsh.

I managed to run the ssh-history command (cat "$HISTFILE" | grep -E "^ssh\s" | sed -e 's/\s*$//' | sort | uniq -c | sort -nr | sed -e "s/^\s*[0-9]*\s//") on bash and I got the history lines contain ssh. But otherwise I cannot make it to work.

Hey mate here is a working solution if your zsh history file looks like this :

: 1612859817:0;composer require box/spout
: 1612860397:0;serve
: 1612864497:0;g stash
: 1612864547:0;serve
: 1612864918:0;git stash pop
: 1612864923:0;serve
: 1612865778:0;q
: 1612867006:0;g stash
: 1612867185:0;g stash pop
: 1612867186:0;q
: 1612867375:0;g stash
: 1612868268:0;g stash pop
: 1612875694:0;g status`

Just change the ssh-history() function to :

ssh-history() {
  cat "$HISTFILE" | grep -E "ssh\s" | sed 's/.*;//'| sed -e 's/\s*$//' | sort | uniq -c | sort -nr | sed -e "s/^\s*[0-9]*\s//"
}
commented

Thanks for replying @XpliSyL I am using my own alias shortcuts since 2019.
But okay, I will use it now :)

What about that list box, I tried to use it but it's just echoing?

I don't know much about list box. But as I understood list box just echo in a pleasant way the list that you give him.

I had the same probem as yours as my list of last ssh connection was empty because of the wrong regex pattern in the sed.
Correcting the line has resolved my problem.

commented

Hmm, I corrected the ssh-history line on ssh-connect.sh but I am still having an empty list here.. do I need to check my alias or something?

I am just doing ssh-connect from the same directory :/

I guess that your zsh history file is different than mine...
So the line that I corrected is still not working with your history format :/

Show me the output of this command :
(⚠️ Don't copy the lines that you don't want to share !!)

cat $HISTFILE | head -n 5

And I'll find the right regex sed expression that you need.

commented

Hmm, this is what I get:

: 1592623475:0;defaults write -g NSFileViewer -string info.filesmanager.Files\

: 1592696533:0;brew install lzip
: 1592696601:0;brew install b3sum
: 1592697145:0;brew install oniguruma

Hmmmm it's definitly the same format. So if your history file contain some commands like

ssh username@ssh.server.com

It should return the line.

When you do :

cat $HISTFILE | grep ssh

Do you have some ssh commands ?

My last hypothesis would be that list box might not work on your system (macos). I tested it in debian and I don't have any problem.

If the last commands return you some ssh lines and list box don't show them then I won't be able to help you anymore :(

salut jutilise oh my zsh jai installer le plugin en manuelle dans le dossier /opt et quand jexecute il ne maffiche pas le connection ssh avant pourtant quand jaffiche mon $histfile jai bien mon historique peut tu maider stp