Project Access
- Made more POSIX compliant - pnew: Now accepts a remote git repo - pnew: Creates git repo on new (not git) projects Aliases - Dev aliases moved to this repo instead of dotfiles - Create aliases when the underlying programs are installed - Alias to copy my template .gitignore to current directory
This commit is contained in:
26
10x_alias.sh
Normal file
26
10x_alias.sh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Git
|
||||||
|
git_push_all_changes() {
|
||||||
|
git add . && git commit -am "${1}" && git push
|
||||||
|
}
|
||||||
|
alias git_just_push=git_push_all_changes
|
||||||
|
alias cd_root='cd $(git rev-parse --show-toplevel 2>/dev/null || echo ".")'
|
||||||
|
alias cd_git_root=cd_root
|
||||||
|
|
||||||
|
# Tmux
|
||||||
|
command -v tmux >/dev/null && alias ta="tmux a"
|
||||||
|
command -v tmux >/dev/null && alias tat="tmux a -t"
|
||||||
|
command -v tmux >/dev/null && alias tls="tmux ls"
|
||||||
|
command -v tmux >/dev/null && alias tnew="tmux new"
|
||||||
|
command -v tmux >/dev/null && alias tnewt="tmux new -t"
|
||||||
|
|
||||||
|
command -v eza >/dev/null && alias ls="eza --hyperlink --header --git -M --icons=auto --color=never"
|
||||||
|
alias ll='ls -alhF'
|
||||||
|
alias la='ls -Ah'
|
||||||
|
alias lsa="ls -lAFhZ"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
[ ! -f "$GITIGNORE_TEMPLATE" ] || alias cpgi="cp ${GITIGNORE_TEMPLATE} ."
|
||||||
@@ -1,42 +1,58 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# TODO: Alias to quickly add my template .gitignore file to any location
|
# TODO: Alias to quickly add my template .gitignore file to any location
|
||||||
# - Create fuzzy finder for cht.sh & tldr
|
# - Create fuzzy finder for cht.sh & tldr + system man pages + learnxinyminutes github
|
||||||
# - Move all dev prod scripts to its own project
|
|
||||||
|
|
||||||
op() {
|
op() {
|
||||||
local chosen_project
|
if ! command -v fzf >/dev/null; then
|
||||||
chosen_project="$(find -L ~/Code -mindepth 2 -maxdepth 2 -not -path '*/.*' -printf "%T@ %p\n" | sort -nr | cut -d ' ' -f 2- | fzf --prompt='Select a project: ')"
|
echo "Install fzf to use this function."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
if [ -z "$chosen_project" ]; then
|
if [ "$project_dir" = "" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$chosen_project" || return
|
cd "$project_dir" || return
|
||||||
nvim
|
nvim
|
||||||
}
|
}
|
||||||
|
|
||||||
pnew(){
|
pnew() {
|
||||||
local directory
|
if ! command -v fzf >/dev/null; then
|
||||||
directory="$(find -L ~/Code/ -mindepth 1 -maxdepth 1 -not -path '*/.*' -type d | sed '/Squbix\|KeepWorks\|Supra/d' | sort | fzf --prompt='In which directory? ')"
|
echo "Install fzf to use this function."
|
||||||
|
return 1
|
||||||
|
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? ')"
|
||||||
|
|
||||||
# Do nothing and return if user cancelled out
|
# Do nothing and return if user cancelled out
|
||||||
if [ -z "$directory" ]; then
|
if [ "$directory" = "" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local project_name
|
# FIX: User cancelling out here
|
||||||
|
is_clone=$(printf 'yes\nno' | fzf)
|
||||||
|
|
||||||
# Until user provides a good directory name or cancels out
|
if [ "$is_clone" = "yes" ]; then
|
||||||
|
# Clone the repo and open nvim on it
|
||||||
|
printf "Git repo URL: " >&2
|
||||||
|
read -r git_url
|
||||||
|
cd "$directory" || return
|
||||||
|
git clone "$git_url" || cd - >/dev/null && return
|
||||||
|
cd "$(basename "$git_url" | cut -d '.' -f 1)" || return
|
||||||
|
else
|
||||||
|
# Loop until user provides a valid directory name or cancels out
|
||||||
while [ -d "$directory/$project_name" ]; do
|
while [ -d "$directory/$project_name" ]; do
|
||||||
if [ -n "$1" ]; then
|
if [ "$1" != "" ]; then
|
||||||
project_name="$1"
|
project_name="$1"
|
||||||
else
|
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)
|
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
|
fi
|
||||||
|
|
||||||
if [ -z "$project_name" ]; then
|
if [ "$project_name" = "" ]; then
|
||||||
echo "Cancelling..."
|
echo "Cancelling..."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -47,7 +63,9 @@ pnew(){
|
|||||||
done
|
done
|
||||||
|
|
||||||
[ -d "$directory/$project_name" ] || mkdir -p "$directory/$project_name" || return
|
[ -d "$directory/$project_name" ] || mkdir -p "$directory/$project_name" || return
|
||||||
|
|
||||||
cd "$directory/$project_name" || return
|
cd "$directory/$project_name" || return
|
||||||
|
git init || return
|
||||||
|
fi
|
||||||
|
|
||||||
nvim
|
nvim
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Increase (My) Dev Productivity
|
# Increase (My) Dev Productivity
|
||||||
|
|
||||||
- A list of scripts to automate my daily development activities
|
- A list of scripts to automate my daily development activities
|
||||||
@@ -11,6 +10,3 @@
|
|||||||
1. Across all *nic OS
|
1. Across all *nic OS
|
||||||
2. Across sh, bash, zsh
|
2. Across sh, bash, zsh
|
||||||
|
|
||||||
## Todo
|
|
||||||
|
|
||||||
- [ ] Make a bootstrap file that symlinks new files to $XDG_CONFIG_HOME/shell/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user