Skip to content

Instantly share code, notes, and snippets.

View Z-kaien's full-sized avatar
🏠
Working from home

Z-Kaien Z-kaien

🏠
Working from home
View GitHub Profile
@Z-kaien
Z-kaien / gist:94dc5b27cf06fae6176ad136e5804d16
Created May 14, 2024 04:23
Colorful PS1 bash shell prompt string with bash version
\[\e[1;32m\][\u@\h \[\e[0m\]\[\e[1;34m\]{bash \v\V} \W]\[\e[0m\]\$
@Z-kaien
Z-kaien / gist:4c9376de4dc2647c8481fd4f27deea1e
Created May 10, 2024 07:27
Remove $PATH code to put into ~/.bashrc
removePath () {
PATH=${PATH/":$1"/} # Remove if at the end
PATH=${PATH/"$1:"/} # Remove if at the start or in the middle
}
@Z-kaien
Z-kaien / gist:321535b9d1cf5ff08a912bb508de97e7
Created January 8, 2024 13:42
Create a bash history backup
#!/bin/bash
# Directory to store backups
backup_dir="/home/zk/backup/bash_history"
# Define filename with date-time stamp
backup_filename="bash_history-$(date +'%Y-%m-%d-%Hh:%Mm:%Ss').txt"
# Create the backup file
cp ~/.bash_history "$backup_dir/$backup_filename"
#Made with https://ezprompt.net/
#Author: Z-Kaien, [email protected]
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
@Z-kaien
Z-kaien / Correct_GnuPG_Permission.sh
Created June 18, 2023 01:53 — forked from oseme-techguy/Correct_GnuPG_Permission.sh
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
#!/usr/bin/env bash
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
@Z-kaien
Z-kaien / .nanorc
Created May 17, 2023 14:19 — forked from turboezh/.nanorc
Nano editor config (.nanorc)
## Sample initialization file for GNU nano.
##
## Please note that you must have configured nano with --enable-nanorc
## for this file to be read! Also note that this file should not be in
## DOS or Mac format, and that characters specially interpreted by the
## shell should not be escaped here.
##
## To make sure a value is disabled, use "unset <option>".
##
## For the options that take parameters, the default value is given.
@Z-kaien
Z-kaien / git-aliases.md
Created May 14, 2023 12:17 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc