From 0a09cb729724bc35a09a69cb1f5cfb7994d7ffcd Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Tue, 2 May 2023 10:30:41 +0300 Subject: [PATCH] feat: updates --- .config/nvim/lua/casraf/remap.lua | 5 +++ aliases.sh | 9 +++- completions/_prj | 2 +- functions.sh | 72 +++++++++++++++++++++---------- 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/.config/nvim/lua/casraf/remap.lua b/.config/nvim/lua/casraf/remap.lua index b717d525..37cc6223 100644 --- a/.config/nvim/lua/casraf/remap.lua +++ b/.config/nvim/lua/casraf/remap.lua @@ -35,6 +35,11 @@ vim.keymap.set("x", "p", [["_dP]], { desc = "Paste over selection, keep -- next greatest remap ever : asbjornHaland vim.keymap.set({ "n", "v" }, "y", [["+y]], { desc = "Yank selection to system clipboard" }) vim.keymap.set("n", "Y", [["+Y]], { desc = "Yank line to system clipboard" }) +-- surround with parens +-- vim.keymap.set("v", "(", "(\"", { desc = "Surround selection with parens" }) + +-- comment line +vim.keymap.set("n", "/", ":CommentToggle", { desc = "Comment line" }) vim.keymap.set({ "n", "v" }, "d", [["_d]], { desc = "Delete selection to void register" }) diff --git a/aliases.sh b/aliases.sh index fa72fa91..330b7b8d 100755 --- a/aliases.sh +++ b/aliases.sh @@ -54,7 +54,7 @@ alias ip6="curl -6 simpip.com --max-time 2 --proto-default https --silent | prep alias iplocal="ipconfig getifaddr en0 | prepend 'iplocal: '" alias ip="iplocal; ip4; ip6" alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" -alias pkgupdate="brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update; sudo gem cleanup; sudo softwareupdate -i -a;" +alias pkgupdate="brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo g em update --system; sudo gem update; sudo gem cleanup; sudo softwareupdate -i -a;" alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> Public key copied to pasteboard.'" alias gundo="git reset --soft HEAD~1" alias unq="sudo xattr -rd com.apple.quarantine" @@ -93,9 +93,14 @@ alias tls="tmux list-sessions" alias tlw="tmux list-windows" alias trl="tmux source-file ~/.config/.tmux.conf" alias trn="tmux rename-session -t" - +alias trm="tmux kill-session -t" alias sync-config="rsync -vtr $DOTFILES/.config/ $HOME/.config/" +# alias tn-simple-scaffold="tn-custom -d $HOME/Dev/simple-scaffold ." +alias tn-df="tn-custom -d $DOTFILES -s dotfiles ." +alias tn-simple-scaffold="tn-prj simple-scaffold" +alias tn-acroasis="tn-custom -d $HOME/Dev/acroasis -s acroasis front server shared landing" + if is_linux; then alias md5="md5sum" fi diff --git a/completions/_prj b/completions/_prj index b87e8173..3792f678 100755 --- a/completions/_prj +++ b/completions/_prj @@ -1,4 +1,4 @@ -#compdef prj prjd +#compdef prj prjd tn-prj prjpath="$(wd path dv)" names=($(ls $prjpath)) diff --git a/functions.sh b/functions.sh index c867a27e..c5b1def3 100755 --- a/functions.sh +++ b/functions.sh @@ -317,33 +317,61 @@ tn-general () { } tn-custom () { - winname=$1 - shift - # Use -d to allow the rest of the function to run - tmux new-session -d -s $winname - # tmux new-window -n $winname + parent="." + for arg in "$@"; do + case "$1" in + -d) + parent="$2" + winname=$(basename $parent) + shift 2 + ;; + -s) + winname="$2" + shift 2 + ;; + esac + done + tmux has-session -t $winname 2>/dev/null + if [[ "$?" == "0" ]]; then + tmux attach-session -t $winname + return 0 + fi - # set as array from argv dirs=("$@") - # -d to prevent current window from changing + + echo "Creating new session $winname on $parent with dirs: $dirs" + tmux new-session -d -s $winname -n general -c $parent for dir in ${dirs[@]}; do + dir="$parent/$dir" tabname=$(basename $dir) - echo "tabname=$tabname" - sleep 0.1 - tmux new-window -d -n $tabname -c "$dir" - echo "tmux new-window -d -n $tabname -c $dir" - sleep 0.1 - tmux send-keys -t $winname:$tabname "v ." Enter - echo "tmux send-keys -t $winname:$tabname v . Enter" - sleep 0.1 - echo "tmux split-pane -d -h -t $winname:$tabname -c $dir" - tmux split-pane -d -h -t $winname:$tabname -c "$dir" + if [[ $tabname == "." ]]; then + tabname="$winname" + fi + + # sleep 0.1 + # echo new-window -n $tabname -c $dir + tmux new-window -n $tabname -c $dir + # echo + + # sleep 0.1 + # echo send-keys -t $winname:$tabname v . Enter + tmux send-keys -t $winname:$tabname v Enter + # echo + + # sleep 0.1 + # echo split-window -h -t $winname:$tabname -c $dir + tmux split-window -h -t $winname:$tabname -c $dir + # echo done - sleep 1 - # -d to detach any other client (which there shouldn't be, - # since you just created the session). - echo "tmux attach-session -d -t $winname" - tmux attach-session -d -t $winname + + tmux select-window -t $winname:0 + tmux attach -t $winname +} + +tn-prj() { + prj="$1" + shift + tn-custom -d "$HOME/Dev/$prj" -s "$prj" . $@ }