tldr
because I am too impatient to read through man pages or google the exact syntax for what I want to do.Sudo !!
It reruns the last command as sudo.
Pretty useful since I’m always forgetting.
cd
every single day.Seems like an appropriate place to share https://github.com/agarrharr/awesome-cli-apps
I’m a fan of ripgrep and lsd in particular.
sl
control+R
in bash, it lets you quickly search for previously executed commands.
its very useful and makes things much quicker, i recommend you give it a try.
Not a command but bang expansions. For example
!?
is the args of last command useful for stuff likemkdir foo ; cd !?
https://www.redhat.com/sysadmin/bash-bang-commands learn these. you suck at using your computer if you don’t know them.
Is there something similar in fish shell?
deleted by creator
CTR + u will delete the whole command. I use that a lot so I don’t have to backspace. It’s saved me a ton of time
Related: Alt +
.
, to cycle through arguments used in previous commands
sudo !!
to rerun last command as sudo.history
can be paired with!5
to run the fifth command listed in history.Fifth as in fifth most recent command or fifth oldest?
I believe it’s the fifth oldest - I think
!-5
will get you the fifth impost recent, but I was shown that and haven’t put it into practice.The most common usecase I do is something like
history | grep docker
to find docker commands I’ve ran, then use!
followed by the number associated with the command I want to run in history.
pv (Pipe Viewer) is a command line tool to view verbose information about data streamed/piped through it. The data can be of any source like files, block devices, network streams etc. It shows the amount of data passed through, time running, progress bar, percentage and the estimated completion time.
ls
jq
Not a specific command, but I learned recently you can just dump any executable script into ~/bin and run it from the terminal.
I suffer greatly from analysis paralysis, I have a very hard time making decisions especially if there’s many options. So I wrote a script that reads a text file full of tasks and just picks one. It took me like ten minutes to write and now I spend far more time doing stuff instead of doing nothing and feeling badly that I can’t decide what to do.
I think the standard is ~/.local/bin, for the people that like standards.
This is because
$HOME/bin
is in yourenvironment variable. You can add more paths that you’d like to execute scripts from, like a personal git repo that contains your scripts.
Since nobody has said yet, I use screen pretty heavily. Want to run a long running task, starting it from your phone? Run screen to create a detachable session then the long running command. You can then safely close out of your terminal or detach with ctrl a, d and continue in your terminal doing something else. screen -r to get back to it.
Don’t use
screen
, but I do usetmux
pretty heavily.I recently switched to tmux and boy, it’s way better. I basically use only tmux now anymore. Creating panes to have two processes in one glance, multiple windows, awesome. Plus all the benefits of screen.
Try zellij. Not as popular as tmux, but very intuitive to use.
Maybe someone reading wants to now about
prefix+s
. This doubles your excitement.
How does screen / tmux work when detached from a session, how does it keep the session alive (both when running locally, and while ssh:ing to a server)? Is there a daemon involved?
In a similar vein,
nohup
lets you send tasks to the background and seems to be everywhere.I Always forget to run screen first, so I just rely heavily on dtach
Simply change your terminal command to execute the terminal multiplexer of your choice.
man terminal_of_choice
, look for (start) command.
Also, screen can connect to an UART device or serial or anything that offers up a TTY