Serhat Teker is the software engineer who wrote these articles.
I created this Tech Blog to help me remember the things I’ve learned in the past, so my future-self doesn’t have to re-learn them in the future.
How to Remove Duplicates in $PATH zsh
It is so easy to do that in zsh:
typeset -U path That’s all.
As you can imagine -U stands for ‘unique’. From doc:
-U For arrays (but not for associative arrays), keep only the first occurrence of each duplicated value. This may also be set for colon-separated special parameters like PATH or FIG‐ NORE, etc. This flag has a different meaning when used with Btw. just care it is not -u.
How to Add Path Uniquely to $PATH
There are 2 easy options for this: Add as a “configuration” or a “function”.
Configuration Add below into your .profile/.bash_profile/.zprofile. You can add it into .bashrc/.zshrc as well but I do not prefer this method. Since environment variables should be set in ~/.profile.
Add a path to $PATH if it is not already in $PATH:
[[ ":$PATH:" != ":/path/to/add:" ]] && PATH="${PATH}:/path/to/add" For instance add ~/projects dir to $PATH:
[[ ":$PATH:" !
Restore Tmux Sessions After Reboot
OK, we see how we save and restore our sessions in tmux. Look at this article Restore Tmux Sessions
But after rebooting the system how can we start the saved sessions? Here what I was doing before:
To restore sessions after reboot I run:
$ tmux new-session Then I hit prefix + ctrl-r
This restores all of my sessions and windows, but it also leaves me with the “extra” session that was created with new-session.
Restore Tmux Sessions
tmux is a great tool for “black panel geeks” like me.
For those who don’t know tmux, it is a terminal multiplexer for Unix-like operating systems. It enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.
It is really great for handling terminal sessions whether local or remote.
Git - Delete Branches
Before deleting any branch if you want to know your branches just run:
$ git branch -a The output will be like:
*master feature remote/origin/master remote/origin/feature Now;
Delete Local Branch $ git branch -d <branch_name> -d flag is for “delete” as you may assume. In addition to that, the -d flag only deletes the branch if it has already been fully merged in its upstream branch. You can also use -D, which is for –delete –force, which deletes the branch “irrespective of its merged status.