vim new file
This commit is contained in:
+14
@@ -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'
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1 @@
|
||||
jiolskdjflksdjf
|
||||
+90
-4
@@ -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 \<C-L>"
|
||||
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 \<C-L>"
|
||||
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 <buffer> <leader>a :call NetrwAddPath()<CR>
|
||||
augroup END
|
||||
|
||||
Reference in New Issue
Block a user