README.MD typo fix
Aliases - Moved to appropriately named file - Added aliases for copying git-template and prettier-template - Fix to git_push_all_changes function Nvims - Compacted the function Project Access - pnew() updated to clone remore repo or create a new one from scratch depending on options provided
This commit is contained in:
@@ -2,11 +2,16 @@
|
|||||||
|
|
||||||
# Git
|
# Git
|
||||||
git_push_all_changes() {
|
git_push_all_changes() {
|
||||||
|
if [ "$1" = "" ]; then
|
||||||
|
echo "Please provide a commit message."
|
||||||
|
return 126
|
||||||
|
fi
|
||||||
git add . && git commit -am "${1}" && git push
|
git add . && git commit -am "${1}" && git push
|
||||||
}
|
}
|
||||||
alias git_just_push=git_push_all_changes
|
alias git_just_push=git_push_all_changes
|
||||||
alias cd_root='cd $(git rev-parse --show-toplevel 2>/dev/null || echo ".")'
|
alias cd_root='cd $(git rev-parse --show-toplevel 2>/dev/null || echo ".")'
|
||||||
alias cd_git_root=cd_root
|
alias cd_git_root=cd_root
|
||||||
|
[ ! -f "$GITIGNORE_TEMPLATE" ] || alias cpgi='cp ${GITIGNORE_TEMPLATE} .'
|
||||||
|
|
||||||
# Tmux
|
# Tmux
|
||||||
command -v tmux >/dev/null && alias ta="tmux a"
|
command -v tmux >/dev/null && alias ta="tmux a"
|
||||||
@@ -23,4 +28,4 @@ alias lsa="ls -lAFhZ"
|
|||||||
alias path="printenv | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n'"
|
alias path="printenv | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n'"
|
||||||
command -v fzf >/dev/null && alias path="printenv | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n' | fzf"
|
command -v fzf >/dev/null && alias path="printenv | grep ^PATH= | sed 's/^PATH=//' | tr ':' '\n' | fzf"
|
||||||
|
|
||||||
[ ! -f "$GITIGNORE_TEMPLATE" ] || alias cpgi="cp ${GITIGNORE_TEMPLATE} ."
|
[ ! -f "$PRETTIER_TEMPLATE" ] || alias cpprc='cp ${PRETTIER_TEMPLATE} .'
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
url_encode(){
|
|
||||||
python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.stdin.read()))" <<< "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
alias gicp="cp ~/.gitignore ."
|
|
||||||
12
10x_nvim.sh
12
10x_nvim.sh
@@ -2,16 +2,14 @@
|
|||||||
|
|
||||||
# Nvim Distro-Switcher
|
# Nvim Distro-Switcher
|
||||||
alias nvim-lazy="NVIM_APPNAME=nvim-lazy nvim"
|
alias nvim-lazy="NVIM_APPNAME=nvim-lazy nvim"
|
||||||
alias OldConfig="NVIM_APPNAME=oldconfig nvim"
|
|
||||||
nvims() {
|
nvims() {
|
||||||
items=$(find -L "$HOME"/.config -maxdepth 2 -name "init.lua" -type f -execdir sh -c 'pwd | xargs basename' \;)
|
config=$(find -L "$HOME"/.config -maxdepth 2 -name "init.lua" -type f -execdir sh -c 'pwd | xargs basename' \; | fzf --prompt=" Neovim Config ")
|
||||||
config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config " --height=~50% --layout=reverse --border --exit-0)
|
|
||||||
if [ -z "$config" ]; then
|
if [ "$config" = "" ]; then
|
||||||
echo "Nothing selected"
|
echo "Nothing selected"
|
||||||
return 0
|
return 0
|
||||||
elif [ "$config" = "default" ]; then
|
|
||||||
config=""
|
|
||||||
fi
|
fi
|
||||||
NVIM_APPNAME=$config nvim "$@"
|
NVIM_APPNAME=$config nvim "$@"
|
||||||
}
|
}
|
||||||
|
# Nvim Distro-Switcher
|
||||||
|
alias nvim-lazy="NVIM_APPNAME=nvim-lazy nvim"
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# TODO: Alias to quickly add my template .gitignore file to any location
|
# TODO:
|
||||||
# - Create fuzzy finder for cht.sh & tldr + system man pages + learnxinyminutes github
|
# - Create fuzzy finder for cht.sh & tldr + system man pages + learnxinyminutes github
|
||||||
|
|
||||||
|
|
||||||
|
# Quick open project files in NVIM
|
||||||
op() {
|
op() {
|
||||||
if ! command -v fzf >/dev/null; then
|
if ! command -v fzf >/dev/null; then
|
||||||
echo "Install fzf to use this function."
|
echo "Install fzf to use this function."
|
||||||
return 1
|
return 127
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# %T => Sort by last modified
|
||||||
|
# @ => time displayed in seconds (since 1.1.1970)
|
||||||
|
# %p => Directory path
|
||||||
project_dir="$(find -L ~/Code -mindepth 2 -maxdepth 2 -not -path '*/.*' -printf "%T@ %p\n" | sort -nr | cut -d ' ' -f 2- | fzf --prompt='Select a project: ')"
|
project_dir="$(find -L ~/Code -mindepth 2 -maxdepth 2 -not -path '*/.*' -printf "%T@ %p\n" | sort -nr | cut -d ' ' -f 2- | fzf --prompt='Select a project: ')"
|
||||||
|
|
||||||
# Do nothing and return if user cancelled out
|
# Do nothing and return if user cancelled out
|
||||||
@@ -16,14 +21,15 @@ op() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$project_dir" || return
|
cd "$project_dir" || return 126
|
||||||
nvim
|
nvim
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Quick create new projects
|
||||||
pnew() {
|
pnew() {
|
||||||
if ! command -v fzf >/dev/null; then
|
if ! command -v fzf >/dev/null; then
|
||||||
echo "Install fzf to use this function."
|
echo "Install fzf to use this function."
|
||||||
return 1
|
return 127
|
||||||
fi
|
fi
|
||||||
|
|
||||||
directory="$(find -L ~/Code/ -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d | sed '/Squbix\|KeepWorks\|Supra/d' | sort | fzf --prompt='Creating new project. In which directory? ')"
|
directory="$(find -L ~/Code/ -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d | sed '/Squbix\|KeepWorks\|Supra/d' | sort | fzf --prompt='Creating new project. In which directory? ')"
|
||||||
@@ -33,38 +39,41 @@ pnew() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# FIX: User cancelling out here
|
is_clone=$(printf 'no\nyes' | fzf --prompt='Clone from remote repo?')
|
||||||
is_clone=$(printf 'yes\nno' | fzf)
|
|
||||||
|
# Do nothing and return if user cancelled out
|
||||||
|
if [ "$is_clone" = "" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$is_clone" = "yes" ]; then
|
if [ "$is_clone" = "yes" ]; then
|
||||||
# Clone the repo and open nvim on it
|
# Clone the repo and open nvim on it
|
||||||
printf "Git repo URL: " >&2
|
printf "Git repo URL: "
|
||||||
read -r git_url
|
read -r git_url
|
||||||
cd "$directory" || return
|
cd "$directory" || return 126
|
||||||
git clone "$git_url" || cd - >/dev/null && return
|
git clone "$git_url" || cd - >/dev/null && return
|
||||||
cd "$(basename "$git_url" | cut -d '.' -f 1)" || return
|
cd "$(basename "$git_url" | cut -d '.' -f 1)" || return 126
|
||||||
else
|
else
|
||||||
# Loop until user provides a valid directory name or cancels out
|
# Loop until user provides a valid directory name or cancels out
|
||||||
while [ -d "$directory/$project_name" ]; do
|
while [ -d "$directory/$project_name" ]; do
|
||||||
if [ "$1" != "" ]; then
|
project_name=$(find -L "$directory" -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d | fzf --print-query -e +i --prompt='Project name (AVOID EXISTING ONES BELOW): ' | head -1)
|
||||||
project_name="$1"
|
|
||||||
else
|
|
||||||
project_name=$(find -L "$directory" -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d | fzf --print-query -e +i --prompt='Project name (AVOID EXISTING ONES BELOW): ' | head -1)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$project_name" = "" ]; then
|
if [ "$project_name" = "" ]; then
|
||||||
echo "Cancelling..."
|
echo "Cancelling..."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$directory/$project_name" ]; then
|
if [ -d "$directory/$project_name" ] || [ -e "$directory/$project_name" ]; then
|
||||||
echo "'$directory/$project_name' already exists"
|
echo "$directory/$project_name already exists"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -d "$directory/$project_name" ] || mkdir -p "$directory/$project_name" || return
|
if [ ! -d "$directory/$project_name" ] && [ ! -e "$directory/$project_name" ]; then
|
||||||
cd "$directory/$project_name" || return
|
mkdir -p "$directory/$project_name" || return 126
|
||||||
git init || return
|
fi
|
||||||
|
|
||||||
|
cd "$directory/$project_name" || return 126
|
||||||
|
git init || return 126
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nvim
|
nvim
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- Scripts should be symlinked to $XDG_CONFIG_HOME/shell/ directory
|
- Scripts should be symlinked to $XDG_CONFIG_HOME/shell/ directory
|
||||||
- ~/.profile should source everything inside $XDG_CONFIG_HOME/shell
|
- ~/.profile should source everything inside $XDG_CONFIG_HOME/shell
|
||||||
- Keep them as portable as possible
|
- Keep them as portable as possible:
|
||||||
1. Across all *nic OS
|
1. Across all *nix OS
|
||||||
2. Across sh, bash, zsh
|
2. Across sh, bash, zsh
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -z "$XDG_CONFIG_HOME" ]; then
|
if [ "$XDG_CONFIG_HOME" = "" ]; then
|
||||||
echo "Config directory (shell variable XDG_CONFIG_HOME) not setup in the computer"
|
echo "Config directory (shell variable XDG_CONFIG_HOME) not setup in the computer"
|
||||||
return 1
|
return 126
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -d "$XDG_CONFIG_HOME/shell/" ] || mkdir "$XDG_CONFIG_HOME/shell/" || return
|
if [ ! -d "$XDG_CONFIG_HOME/shell/" ] && [ ! -e "$XDG_CONFIG_HOME/shell/" ]; then
|
||||||
|
mkdir "$XDG_CONFIG_HOME/shell/" || return 126
|
||||||
|
fi
|
||||||
|
|
||||||
for x_10 in "$PWD"/10x*.sh; do
|
for x_10 in "$PWD"/10x*.sh; do
|
||||||
ln -sf "$x_10" "$XDG_CONFIG_HOME/shell/"
|
ln -sf "$x_10" "$XDG_CONFIG_HOME/shell/"
|
||||||
|
|||||||
Reference in New Issue
Block a user