Show HN: ssh and cd get married
21–30 of 51 posts
Re: Show HN: ssh and cd get married
#22TL;DR: a 3 line exercise in bash argument munging. t="${!#}" c=("ssh" "-t" "${@:1:$(($#-1))}" "${t%:*}" "cd ${t##*:}; \$SHELL -l") "${c[@]}" That's literally the whole repo.
Literally. We both know that it would've been easier to write this in Python, Ruby, Javascript, etc., but at the cost of using an "uncool" language I was able to solve the problem in three lines with only bash as a dependency. Pull requests welcome.
Congratulations on getting the *NIX philosophy right.
Re: Show HN: ssh and cd get married
#23Then you can put
alias cd='sshcd'
in your .bashrc, and you won't have to distinguish between local and remote paths ever again.Re: Show HN: ssh and cd get married
#24I hate little extensions like this because if I make them part of my workflow, I am completely hindered when I find myself on a machine that doesn't have this. (Every other machine in the world.)
WARNING: SHAMELESS SELF-PROMOTION BELOW
Unless, you know, you used something like homes(h)ick...
Re: Show HN: ssh and cd get married
#25Even better: make the script work with local paths as well. Then you can put alias cd='sshcd' in your .bashrc, and you won't have to distinguish between local and remote paths ever again.
What do you think?
Re: Show HN: ssh and cd get married
#26Alternatively, you could keep a tmux session open on the server and just attach it on connect. That way you can have everything arranged just the way you left it on disconnect. Same applications running, multiple windows, splits, etc. And you don't even need to start a new shell on connect. ssh user@host -t tmux attach You can add an alias for it. alias backtowork='ssh -t user@host tmux attach -t worksession' The las…
I use screen and it works well. The first thought when I saw this post was of screen and tmux. Anyone spending any kind of serious time in remote server through ssh should use screen/tmux.
Re: Show HN: ssh and cd get married
#27I think it's a cool exploration. Thanks for sharing.
Re: Show HN: ssh and cd get married
#28It would be much more useful if you can make an scp with autocomplete by pressing tab in the terminal. scp root@host:/long(tab)_file_name .
Re: Show HN: ssh and cd get married
#29It would be much more useful if you can make an scp with autocomplete by pressing tab in the terminal. scp root@host:/long(tab)_file_name .
Re: Show HN: ssh and cd get married
#30It would be much more useful if you can make an scp with autocomplete by pressing tab in the terminal. scp root@host:/long(tab)_file_name .
You can check out my dotfiles (https://github.com/christianbundy/dotfiles), but I'm pretty sure that the functionality came standard with one of my Zsh submodules, Prezto (https://github.com/sorin-ionescu/prezto).