10 protips I wish I knew sooner as a software dev (beginner) anthony explains

  Рет қаралды 17,944

anthonywritescode

anthonywritescode

Күн бұрын

here's ten quick things you can learn to level up your bash / terminal skills.
- github.com/asottile/scratch/w...
- more powerful than control-C: • more powerful than con...
- fc / fix command: • bash protip: fc "fix c...
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/asottile
stream github: github.com/anthonywritescode
I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!

Пікірлер: 53
@mCoding
@mCoding 2 жыл бұрын
Wow I didn't realize !! is treated like an escape sequence, so it will expand even inside quotes (double quotes, but not single quotes). I can imagine someone going echo "hello world!!" and being very confused.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
heh and this is why I almost always use hard-quotes (single quotes)
@TheKittko
@TheKittko 2 жыл бұрын
hah, quite the gotcha indeed
@blumer4029
@blumer4029 2 жыл бұрын
Or trying to do a commit with the inline message "Done!!"
@andrewf8366
@andrewf8366 2 жыл бұрын
I actually had this happen to me early on when using bash.
@TheKittko
@TheKittko 2 жыл бұрын
one pro tip i use all the time is jobs. Ctrl+Z to suspend/pause the current shell command and then fg to get back to it. jobs to list all currently suspended commands.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
yep -- I go over that in kzbin.info/www/bejne/opy0gIR3mJtokKM
@StanislavSchmidt1
@StanislavSchmidt1 2 жыл бұрын
Nice, some really good-to-knows there :) I also like Ctrl+p+q for detaching from an interactive docker container.
@_baco
@_baco 2 жыл бұрын
I think `Ctrl+Shift+u` for unicode is not Bash, but rather a GTK+ feature; which is where the shell session is running (inside a gnome-terminal, which happens to be GTK+). It also works in many other shells inside a GTK-based terminal, and further-more even in the web-browser. For instance, it doesn't work on Bash running inside Alacritty, and it works different on Kitty Terminal
@anthonywritescode
@anthonywritescode 2 жыл бұрын
indeed! a few have shown me this before as well
@john_critchley
@john_critchley 2 жыл бұрын
Should have mentioned this (coppied from bash(1)): operate-and-get-next (C-o) Accept the current line for execution and fetch the next line relative to the current line from the history for editing. A numeric argument, if supplied, specifies the history entry to use instead of the current line. Basically in bash, after doing a reverse search (C-r) you can run that command and get the next ready to run, and the next and the next... (possibly changing them before running) This is very useful.
@jinhopark3671
@jinhopark3671 2 жыл бұрын
Absolutely love these kind of videos! Thanks :)
@joshsnyder5882
@joshsnyder5882 2 жыл бұрын
afaik ctrl-shift-u is a Gnome-specific unicode entry mode. It works everywhere in Gnome, but not outside of Gnome.
@_baco
@_baco 2 жыл бұрын
Actually, it's GTK+ specific. It doesn't work, even inside GNOME, if the application is not GTK-based. For instance Alacritty or XTerm
@essamgouda1609
@essamgouda1609 2 жыл бұрын
As always brilliant content !
@davehouser1
@davehouser1 2 жыл бұрын
Wow, very cool stuff :) didn't know about reverse-search. I always just grep on my history command, then use `!` for the entry I want to run. If I want to edit it I use `!:p`. Re: fc, I usually run `set -o vi` so I can run vi motions from the terminal, from there I can use `v` to edit commands. Nice post!
@TheMaxCacao
@TheMaxCacao 2 жыл бұрын
I use mcfly as a ctrl-r extension. It’s recommendation algo and easy viewing of previous commands is really usefull
@jamesmunroe6558
@jamesmunroe6558 Жыл бұрын
You're a total boss, dude! Your videos are gold!
@lukajeliciclux3074
@lukajeliciclux3074 2 жыл бұрын
Great video. Can I fork the wiki for the references?
@souravdhar47
@souravdhar47 2 жыл бұрын
how to get out of the editor after the fc command?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
just quit the editor like normal -- (so if it's vim, you'd `:wq`, if it's babi you'd `^X`)
@Granteparton
@Granteparton 2 жыл бұрын
Cool keyboard, what is it?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
it's the kinesis freestyle pro! here's my thoughts on it: kzbin.info/www/bejne/eovKdIiNm553kK8
@tcarreira
@tcarreira 2 жыл бұрын
I find it easier to memorize the ESC+ instead. Eg: ESC+. will write the paste the last argument. ESC+backspace will delete the last word. etc...
@anthonywritescode
@anthonywritescode 2 жыл бұрын
I assume you map capslock to control, otherwise those are quite the stretch!
@CollinJS
@CollinJS 2 жыл бұрын
Alt+. will also produce the same effect, though the escape method allows you to fully press and release escape before tapping dot, etc.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
you can also do control-[ + . as well
@voytechj
@voytechj 2 жыл бұрын
Reverse search (Crtl-r) is pretty universal. It works in python REPL, bash, zsh, PowerShell and many more. You can import prompt_toolkit and replace "input" with "prompt" and have your own reverse search. Its very easy: from prompt_toolkit import PromptSession session = PromptSession() while True: answer = session.prompt("Give me some input: ") print(f"You said: {answer}") if answer == "exit": break
@anthonywritescode
@anthonywritescode 2 жыл бұрын
^R is a readline feature -- all those things use readline when available (python on windows for example does not support it, and very frequently pyenv-compiled python doesn't either)
@voytechj
@voytechj 2 жыл бұрын
@@anthonywritescode Just checked both cmd and new Microsoft Terminal on windows and reverse search works in python with no problem.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
you must've installed readline -- the official distributions do not come with functioning readline
@voytechj
@voytechj 2 жыл бұрын
@@anthonywritescode You are right, I installed pyreadline. Forgot about this module
@leyuskc
@leyuskc Жыл бұрын
ctrl+. for emoji chart or tabel , unlike ctrl+shift+u youdont have to remember the unicode value 😉
@anthonywritescode
@anthonywritescode Жыл бұрын
doesn't work on linux or windows -- must be a mac specific thing
@TheMicho1234
@TheMicho1234 2 жыл бұрын
Hi anthony, FYI, you typed your password while recording your keyboard ...
@dddsa5951
@dddsa5951 2 жыл бұрын
I think he uses a virtual machine to make videos so it doesn't actually matter : }
@anthonywritescode
@anthonywritescode 2 жыл бұрын
yep -- my password is literally "bad password"
@sillybuttons925
@sillybuttons925 2 жыл бұрын
`y` does work on gitlab. Unfortunately know this from experience.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
you poor soul, gl with your choo choos
@sillybuttons925
@sillybuttons925 2 жыл бұрын
@@anthonywritescode "run train is against our coc"
@tandavme
@tandavme 2 жыл бұрын
you can use ctrl - D instead of ~. to close ssh connection. Or get out of the attached docker container terminal
@dddsa5951
@dddsa5951 2 жыл бұрын
Ctrl+D doesn't work if the connection is stuck. For example if your wifi got disconnected while you were ssh'd into a server, neither ctrl+C or ctrl+D will do anything, you will have to close the terminal. But ~. worked to my surprise and it's a nice trick to know
@anthonywritescode
@anthonywritescode 2 жыл бұрын
nope! ~. is specifically needed when the session is stuck and you want to forcibly detach
@guitarfumar
@guitarfumar 2 жыл бұрын
Timestamps would be very much appreciated. 🤙
@anthonywritescode
@anthonywritescode 2 жыл бұрын
if you compile them I'll put them into the description!
@con-f-use
@con-f-use 2 жыл бұрын
Ctrl + x then Ctrl + e opens the current terminal line in an editor, so similar to fc, but is better, because it works across multiple shells and together with history navigation is slightly more powerful.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
you didn't watch the video
@con-f-use
@con-f-use 2 жыл бұрын
​@@anthonywritescode I did, but missed the mention of it also missed the Alt + . (dot) the first time. Just spaced out. At least the info that it works in shells other than bash was not in the vid ;D
@JohnSmith-xf6nb
@JohnSmith-xf6nb Жыл бұрын
@@con-f-use Doesn't work in zsh apparently
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars 2 жыл бұрын
Title should have been useful bash tricks I wish I knew
@anthonywritescode
@anthonywritescode 2 жыл бұрын
not all of them are bash
@cerioscha
@cerioscha 10 ай бұрын
^r is a great one thanks ! There was me doing history | grep git all this time
embedding images in github (beginner - intermediate) anthony explains #416
4:30
how do virtualenvs actually work (advanced) anthony explains #522
16:55
anthonywritescode
Рет қаралды 7 М.
НЫСАНА КОНЦЕРТ 2024
2:26:34
Нысана театры
Рет қаралды 1 МЛН
DAD LEFT HIS OLD SOCKS ON THE COUCH…😱😂
00:24
JULI_PROETO
Рет қаралды 16 МЛН
Useful gadget for styling hair 🤩💖 #gadgets #hairstyle
00:20
FLIP FLOP Hacks
Рет қаралды 9 МЛН
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 46 М.
py-spy saved our python 3.11 rollout (intermediate) anthony explains #568
13:48
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 344 М.
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,6 МЛН
how to ace the coding interview (intermediate) anthony explains #358
24:29
anthonywritescode
Рет қаралды 4,5 М.
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,6 МЛН
The Zsh Shell Tricks I Wish I'd Known Earlier: Boost Terminal Productivity
18:41
Todos os modelos de smartphone
0:20
Spider Slack
Рет қаралды 63 МЛН
İĞNE İLE TELEFON TEMİZLEMEK!🤯
0:17
Safak Novruz
Рет қаралды 346 М.