Earlier quoted context omitted.
Alt + . – use the last word of the previous command. $ cp file.txt /some/annoyingly/deep/target/directory/other.txt $ cd then press Alt + . $ pwd # => /some/annoyingly/deep/target/directory
No, that gives the last word, as you say, we want the dirname of the last word. $ echo foo/bar foo/bar $ echo !$ !$:h foo/bar foo
Unix tricks
161–170 of 232 posts
Re: Unix tricks
#162 ls *.png | parallel convert {} {.}.jpgRe: Unix tricks
#163If I may add a trick: ctrl-z - stops a program bg - sends the stopped program to the background fg - gets the program back to the foreground (interactive mode) very useful in editor sessions or when you want to get rid of the endless download/scp that is blocking your terminal
Another nice job management tool is disown, which lets you log out of your session without killing the job (similar to starting the command with nohup)
Re: Unix tricks
#164Re: Unix tricks
#165 ^x ^e
It opens up the exported EDITOR with a tmp file containing whatever is on the command line.Using SSH, especially on campus/in a train/other places where a wifi connection doesn't long, mosh is really a godsend. In places where mosh isn't practical or available, the following combos are really good to know:
~ . # end ssh connection
~ ? # show available commands
Paired with autossh which will reconnect by itself, it really takes the pain out of traveling while doing remote work.Oh, and when you need to know what the decimal value of 0x65433 is, it's good to know that bash can do stuff like that:
$ echo $((16#65433))
414771
Reading the bash man page is not a bad idea in itself...Re: Unix tricks
#166Re: Unix tricks
#167Earlier quoted context omitted.
ssh-agent and 'ssh -A' is also useful if you have to login to one machine to access another, without having to copy your private key to the first machine. For example if you login remotely to a machine, and want to access a git repository on another: $ eval `ssh-agent -s` $ ssh-add ~/.ssh/id_ $ ssh -A you@firstserver$ git clone git+ssh:// /path/to/repository
I use agent forwarding often, but you still need to be careful, especially if you forward your agent to a machine not under your control. From the ssh man page: Agent forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the agent's UNIX-domain socket) can access the local agent through the forwarded connection. An attacker cannot obtain key material from…
Re: Unix tricks
#168> Compile your own version of 'screen' from the git sources. Most versions have a slow scrolling on a vertical split or even no vertical split at all or just use tmux
Re: Unix tricks
#169Feels very outdated. 1. Use zsh, not bash. AUTO_PUSHD, CORRECT_ALL and tons of other options make some tricks redundant. Also, the zle M-n and M-p are more useful than C-r imo. 2. Use tmux, not screen. 3. Use z ( https://github.com/rupa/z ), not j.py. 4. Use cron, not at. Or even systemd timer units, if you're so inclined. 5. Use public-key authentication and keychain, not password-based SSH. 6. Don't send emails fro…
Re: Unix tricks
#170Only one Vim tip? I'm disappointed. Check out this resource! http://www.rayninfo.co.uk/vimtips.html