diff --git a/ksh/aliases b/ksh/aliases new file mode 100644 index 0000000..20f89d0 --- /dev/null +++ b/ksh/aliases @@ -0,0 +1,14 @@ +alias l='colorls -G' +alias ll='colorls -Gl' +alias la='colorls -GA' +alias lla='colorls -GAl' + +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' + +alias grep='grep --color=auto' + +alias cp="cp -i" +alias df='df -h' + diff --git a/ksh/rm.sh b/ksh/rm.sh new file mode 100755 index 0000000..04f7c5b --- /dev/null +++ b/ksh/rm.sh @@ -0,0 +1,60 @@ +#!/bin/ksh + +# Colors +RESET="$(printf '\033[0m')" +BLUE="$(printf '\033[1;34m')" +RED="$(printf '\033[1;31m')" + +if [ "$#" -eq 0 ]; then + echo "usage: srm file ..." + exit 1 +fi + +for file in "$@"; do + if [ ! -e "$file" ]; then + echo "srm: $file: No such file" + continue + fi + + if [ -d "$file" ]; then + echo "srm: $file: is a directory" + continue + fi + + # -------------------------------------------------------- + # Show filename in blue + # -------------------------------------------------------- + + printf "%s------------------------------------------------------------%s\n" \ + "$BLUE" "$RESET" + + printf "%sFile: %s%s\n" \ + "$BLUE" "$file" "$RESET" + + printf "%s------------------------------------------------------------%s\n" \ + "$BLUE" "$RESET" + + # Show first 10 lines of file + head -n 10 -- "$file" + + printf "%s------------------------------------------------------------%s\n" \ + "$BLUE" "$RESET" + + # -------------------------------------------------------- + # Confirmation in red + # -------------------------------------------------------- + + printf "%sDelete '%s'? [y/N] %s" \ + "$RED" "$file" "$RESET" + + read answer + + case "$answer" in + y|Y|yes|YES) + rm -- "$file" + ;; + *) + echo "Not deleted: $file" + ;; + esac +done diff --git a/packages/install.ksh b/packages/install.ksh new file mode 100644 index 0000000..9154c4a --- /dev/null +++ b/packages/install.ksh @@ -0,0 +1 @@ +jiolskdjflksdjf diff --git a/vim/.vimrc b/vim/.vimrc index bac428b..8c8be1e 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -22,6 +22,7 @@ syntax enable filetype plugin indent on set number +set relativenumber set cursorline set ruler set showcmd @@ -195,7 +196,7 @@ function! ShowKeymapHelp() setlocal noswapfile setlocal nobuflisted setlocal nomodified - setlocal nowrap + setlocal wrap setlocal nonumber setlocal norelativenumber setlocal nocursorline @@ -204,20 +205,18 @@ function! ShowKeymapHelp() \ 'VIM KEYMAPS', \ '===========', \ '', - \ 'Leader key: Space', \ '', \ 'FILES AND BROWSING', \ ' Space e Toggle file browser', \ ' Space f Find project file', \ ' Space o Recently opened files', \ ' Space b List open buffers', + \ ' Space a Create new parent directories and files', \ '', \ 'Inside the file browser:', \ ' Enter Open file or directory', \ ' t Open file in new tab', \ ' - Parent directory', - \ ' % Create file', - \ ' d Create directory', \ ' R Rename file', \ ' D Delete file', \ '', @@ -284,3 +283,90 @@ augroup keymap_help_startup \ call ShowKeymapHelp() | \ endif augroup END + + + + + +" --------------------------------------------------------------------------- +" Space+a inside filemanager create parent directories and files +" --------------------------------------------------------------------------- +function! NetrwAddPath() + let l:base = b:netrw_curdir + let l:name = input('New path (end with / for directory): ') + + if empty(l:name) + return + endif + + let l:path = simplify(l:base . '/' . l:name) + + " A trailing slash means: create directories only. + if l:name =~# '/$' + try + call mkdir(l:path, 'p') + silent execute 'keepalt edit! ' . fnameescape(l:base) + "silent execute "normal \" + echo 'Created directory: ' . l:path + catch + echohl ErrorMsg + echomsg 'Cannot create directory: ' . v:exception + echohl None + endtry + return + endif + + " Create all missing parent directories. + let l:parent = fnamemodify(l:path, ':h') + + try + call mkdir(l:parent, 'p') + + " Create only when the file does not already exist. + if getftype(l:path) ==# '' + call writefile([], l:path, 'b') + elseif isdirectory(l:path) + throw 'Path is a directory: ' . l:path + endif + catch + echohl ErrorMsg + echomsg 'Cannot create file: ' . v:exception + echohl None + return + endtry + + + " Refresh the Netrw file listing. + "silent execute "normal \" + silent execute 'keepalt edit! ' . fnameescape(l:base) + + " Find the main editing window. + let l:target_window = winnr('#') + + " Find the main editing window. + let l:target_window = winnr('#') + + if l:target_window == 0 + \ || getbufvar(winbufnr(l:target_window), '&filetype') ==# 'netrw' + let l:target_window = 0 + + for l:window in range(1, winnr('$')) + if getbufvar(winbufnr(l:window), '&filetype') !=# 'netrw' + let l:target_window = l:window + break + endif + endfor + endif + + " Open the new file in the main editing area. + if l:target_window > 0 + execute l:target_window . 'wincmd w' + endif + + execute 'edit ' . fnameescape(l:path) +endfunction + +augroup netrw_custom_mappings + autocmd! + autocmd FileType netrw nnoremap a :call NetrwAddPath() +augroup END