- Moved existing functions from dotfiles over to this repo.

- Made pnew() loop till a valid name is given.
- Made bootstrap script to symlink all scripts to ~/.config/shell
This commit is contained in:
Pratik Tripathy
2024-02-09 10:04:49 +05:30
parent 44ccbbfe6e
commit 5765e05ec0
6 changed files with 159 additions and 15 deletions

99
.gitignore vendored Normal file
View File

@@ -0,0 +1,99 @@
# ---- KDE Neon ----
# KDE directory preferences
.directory
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# ---- macOS ----
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# ---- IDE ----
# Vim Artifacts
**.swp
lazy-lock.json
.luarc.json
# VS Code Artifacts
/.vscode/
**state.vscdb
**state.vscdb.backup
.vscode/extensions/** # Ignore all Files under .vscode/extensions/
!.vscode/extensions/**/*.json # Only json files inside the .vscode/extensions/ folder
# Intellij IDE Artifacts
.idea/
*.imi
*.jar
*.tar
resharper-host/
tasks/
# ---- Programming Languages ----
# Ignore all downloaded node modules
node_modules/*
dist
dist-ssr
*.local
# Ignore all minified js files
*.min.js
# Log files
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
# Other Files to ignore
**app_stat_v2.db
.ssh/*.pub
**/Package Control.cache
**Cache
*.db
*.qmlc
*.qml
*.jsc
**/contents/images
**/contents/fonts
*kpluginindex.json

View File

@@ -0,0 +1,7 @@
#!/bin/sh
url_encode(){
python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.stdin.read()))" <<< "$1"
}
alias gicp="cp ~/.gitignore ."

17
10x_nvim.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
# Nvim Distro-Switcher
alias nvim-lazy="NVIM_APPNAME=nvim-lazy nvim"
alias OldConfig="NVIM_APPNAME=oldconfig nvim"
nvims() {
items=$(find -L "$HOME"/.config -maxdepth 2 -name "init.lua" -type f -execdir sh -c 'pwd | xargs basename' \;)
config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config  " --height=~50% --layout=reverse --border --exit-0)
if [ -z "$config" ]; then
echo "Nothing selected"
return 0
elif [ "$config" = "default" ]; then
config=""
fi
NVIM_APPNAME=$config nvim "$@"
}

35
10x_project_access.sh Normal file → Executable file
View File

@@ -1,5 +1,9 @@
#!/bin/sh #!/bin/sh
# TODO: Alias to quickly add my template .gitignore file to any location
# - Create fuzzy finder for cht.sh & tldr
# - Move all dev prod scripts to its own project
op() { op() {
local chosen_project local chosen_project
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: ')" 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: ')"
@@ -23,23 +27,24 @@ pnew(){
fi fi
local project_name local project_name
if [ -n "$1" ]; then
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 [ -z "$project_name" ]; then # Until user provides a good directory name or cancels out
echo "You did not chose a project name!!!" while [ -d "$directory/$project_name" ]; do
return 1 if [ -n "$1" ]; then
fi 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 [ -d "$directory/$project_name" ]; then if [ -z "$project_name" ]; then
echo "$directory/$project_name project already exists" echo "Cancelling..."
echo "Try again" return 0
return 1 fi
# TODO: Should allow to reenter the name
fi if [ -d "$directory/$project_name" ]; then
echo "'$directory/$project_name' already exists"
fi
done
[ -d "$directory/$project_name" ] || mkdir -p "$directory/$project_name" || return [ -d "$directory/$project_name" ] || mkdir -p "$directory/$project_name" || return

View File

@@ -10,3 +10,7 @@
- Keep them as portable as possible - Keep them as portable as possible
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/

12
bootstrap.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
if [ -z "$XDG_CONFIG_HOME" ]; then
echo "Config directory (shell variable XDG_CONFIG_HOME) not setup in the computer"
return 1
fi
[ -d "$XDG_CONFIG_HOME/shell/" ] || mkdir "$XDG_CONFIG_HOME/shell/" || return
for x_10 in "$PWD"/10x*.sh; do
ln -sf "$x_10" "$XDG_CONFIG_HOME/shell/"
done