Alternatively, 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…
Show HN: ssh and cd get married
11–20 of 51 posts
Re: Show HN: ssh and cd get married
#12TL;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.
Re: Show HN: ssh and cd get married
#13If you are an Emacs user, Tramp does this, e.g. you can open a file like: /user@example.com:/some/remote/path/file.dat Directory navigation (dired) works too, you can also open a shell in the remote directory (M-x shell)
/sudo:localhost:/etc/hosts
Re: Show HN: ssh and cd get married
#14Re: Show HN: ssh and cd get married
#15Re: Show HN: ssh and cd get married
#16TL;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.
Can you explain this code?
Re: Show HN: ssh and cd get married
#17 autoload -U add-zsh-hook
record_pwd() { pwd > ~/.cwd }
add-zsh-hook chpwd record_pwd
touch ~/.cwd
cd `cat ~/.cwd`Re: Show HN: ssh and cd get married
#18This feels less like a marriage and more like trying to tie two very different animals together.
I'd much prefer if this was some kind of host-alias based magic, where "ssh my_server_web" took my to "my_server:/srv/http/my_site", "ssh my_server_db" took me to my_server and opened mysql, etc.
Re: Show HN: ssh and cd get married
#19You still have to type the path you want to cd to. See previous discussion at https://news.ycombinator.com/item?id=6229001 for possible solutions.
The github example specifies the username to ssh to. Assuming you ssh to the host more than once see man ssh_config and the User parameter.
And screen/tmux, obviously.
Re: Show HN: ssh and cd get married
#20scp root@host:/long(tab)_file_name .