Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It wont find my previous ssh connections on bash/zsh #6

Open
piratx opened this issue Jun 10, 2019 · 8 comments
Open

It wont find my previous ssh connections on bash/zsh #6

piratx opened this issue Jun 10, 2019 · 8 comments

Comments

@piratx
Copy link

piratx commented Jun 10, 2019

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.

wirdman added a commit to wirdman/ssh-connect that referenced this issue Oct 12, 2020
@XpliSyL
Copy link

XpliSyL commented Feb 19, 2021

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//"
}

@piratx
Copy link
Author

piratx commented Feb 19, 2021

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?

@XpliSyL
Copy link

XpliSyL commented Feb 19, 2021

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.

@piratx
Copy link
Author

piratx commented Feb 19, 2021

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 :/

@XpliSyL
Copy link

XpliSyL commented Feb 19, 2021

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 :
(:warning: 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.

@piratx
Copy link
Author

piratx commented Feb 19, 2021

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

@XpliSyL
Copy link

XpliSyL commented Feb 19, 2021

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 :(

@backl1n
Copy link

backl1n commented Oct 12, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants