Fish environment variable for just one command
Happy Fish shell user for years, but I’m never able to remember how to set an environment variable for a single command. Maybe I’ll remember if I write it down:
env SOME_VAR=1 command
All notes tagged with command-line.
Happy Fish shell user for years, but I’m never able to remember how to set an environment variable for a single command. Maybe I’ll remember if I write it down:
env SOME_VAR=1 command
I tend to keep a long-lived tmux session per project that I’m working on. When I want to start a new project though, it carries the old working directory with it. I keep forgetting what I need to do to type it, so hopefully this TIL makes me remember it for the next time.
To switch the current working directory, do a :attach -c <newdir>
. And to do it it even more easily, I bound it in my tmux configuration to Meta-w
:
bind M-w attach -c "#{pane_current_path}"
I often rely on SSH tunnels to forward remote ports locally. For example, to control my remote installation of Resilio Sync. There is a lot of flags you can set, but these are the flags that work best for me:
ssh -CqTnNf -L 8889:localhost:8888 [email protected]
In this example, I forward the remote localhost:8888
port to my local 8889
. The flags do the following:
C
: Compress the data.q
: Silent modus.T
: Disable pseudo-tty allocation.n
: Prevent reading stdin.N
: No remote commands, just forwarding.f
: Run in the background.L
: Specifies the forward.Now, if you want to exit the tunnel, you could kill SSH pkill ssh
, but this will kill all your SSH connections. I multiplex my connections and can run: ssh -O exit [email protected]
. You would need this in your ~/ssh/.config
to be able to do that as well:
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
Rust never stops to amaze me with its command-line tools and today I found out about cargo-generate
which enables you to setup a repository which will function as a project template for Rust.
As an example, to pull down the repository and start a new project, you would do:
cargo generate --git https://github.com/githubusername/mytemplate.git --name myproject
I have this tick where I continuously check that my tools are running the latest version. I guess you could call it a form of FOMO.
Luckily, Rust has me covered with two packages which check that for me.
cargo-outdated which check that your project dependenies are up-to-date. And cargo-update which checks that your Rust executables, like cargo-edit are running the latest version.
It will even update itself!