Add autoinstall for packages (vim-plug, starship, ...)
This commit is contained in:
		
							parent
							
								
									e448e719e8
								
							
						
					
					
						commit
						866bbcae20
					
				
					 5 changed files with 57 additions and 101 deletions
				
			
		
							
								
								
									
										23
									
								
								.bin/autoinstall-packages
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										23
									
								
								.bin/autoinstall-packages
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| #!/usr/bin/env sh | ||||
| 
 | ||||
| vim_autoload_dir="$HOME/.config/vim/autoload" | ||||
| if [ ! -f "$vim_autoload_dir/plug.vim" ] | ||||
| then | ||||
| 	mkdir -p "$vim_autoload_dir" | ||||
| 	cd "$vim_autoload_dir" || exit | ||||
| 	curl -o "plug.vim" "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" | ||||
| 	[ -x "$(command -v vim)" ] && yes | vim +'PlugInstall --sync' +qa --not-a-term | ||||
| fi | ||||
| 
 | ||||
| nvim_dir="$HOME/.config/nvim" | ||||
| if [ ! -d "$nvim_dir" ] | ||||
| then | ||||
| 	git clone https://github.com/AstroNvim/AstroNvim "$nvim_dir" | ||||
| 	[ -x "$(command -v nvim)" ] && nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' | ||||
| fi | ||||
| 
 | ||||
| if [ ! -x "$(command -v starship)" ] | ||||
| then | ||||
| 	mkdir -p "$HOME/.local/bin" | ||||
| 	curl -sS "https://starship.rs/install.sh" | BIN_DIR="$HOME/.local/bin" FORCE=1 sh | ||||
| fi | ||||
|  | @ -63,7 +63,7 @@ alias xdebug='XDEBUG_CONFIG="remote_host=127.0.0.1 remote_port=9003"' | |||
| 
 | ||||
| [ -x "$(command -v bat)" ] && alias cat='bat -pp' | ||||
| 
 | ||||
| [ -x "$(command -v exa)" ] && alias ls='exa -lhF --git --icons --color=always --color-scale --time-style=long-iso' | ||||
| [ -x "$(command -v exa)" ] && alias ls='exa -lhF --git --icons --color=always --color-scale --time-style=long-iso --group-directories-first' | ||||
| 
 | ||||
| [ -x "$(command -v rmtrash)" ] && alias rm='rmtrash' | ||||
| [ -x "$(command -v rmdirtrash)" ] && alias rmdir='rmdirtrash' | ||||
|  |  | |||
|  | @ -7,6 +7,8 @@ then | |||
| 	rm "$HOME/.zshrc" | ||||
| fi | ||||
| 
 | ||||
| autoinstall-packages | ||||
| 
 | ||||
| # Set name of the theme to load --- if set to "random", it will | ||||
| # load a random theme each time oh-my-zsh is loaded, in which case, | ||||
| # to know which specific one was loaded, run: echo $RANDOM_THEME | ||||
|  | @ -67,6 +69,18 @@ HIST_STAMPS="yyyy-mm-dd" | |||
| # Would you like to use another custom folder than $ZSH/custom? | ||||
| ZSH_CUSTOM=$ZDOTDIR/custom | ||||
| 
 | ||||
| function omz_install_custom_plugin() { | ||||
| 	plugin_path="$ZSH_CUSTOM/plugins/$1" | ||||
| 	if [ ! -d "$plugin_path" ] | ||||
| 	then | ||||
| 		echo "Installing plugin $1" | ||||
| 		git clone "$2" "$plugin_path" >/dev/null 2>&1 | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| omz_install_custom_plugin "zsh-syntax-highlighting" "https://github.com/zsh-users/zsh-syntax-highlighting.git" | ||||
| 
 | ||||
| 
 | ||||
| # Which plugins would you like to load? | ||||
| # Standard plugins can be found in $ZSH/plugins/ | ||||
| # Custom plugins may be added to $ZSH_CUSTOM/plugins/ | ||||
|  | @ -88,6 +102,7 @@ plugins=( | |||
| 	'safe-paste' | ||||
| 	'sudo' | ||||
| 	'vi-mode' | ||||
| 	'zsh-syntax-highlighting' | ||||
| ) | ||||
| 
 | ||||
| source $ZSH/oh-my-zsh.sh | ||||
|  | @ -106,7 +121,4 @@ export SAVEHIST=1000000 | |||
| export HISTSIZE=1000000 | ||||
| export HISTFILE="$HOME/.cache/zsh_history" | ||||
| 
 | ||||
| # Load zsh-syntax-highlighting; should be last. | ||||
| source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null | ||||
| 
 | ||||
| [ -x "$(command -v starship)" ] && eval "$(starship init zsh)" | ||||
|  |  | |||
|  | @ -1,47 +0,0 @@ | |||
| # doas-zsh-plugin | ||||
| 
 | ||||
| Easily prefix your current or previous commands with `doas` by pressing <kbd>esc</kbd> twice | ||||
| 
 | ||||
| To use it, add the following to your zshrc: | ||||
| 
 | ||||
| ```console | ||||
| plugins=(doas) | ||||
| ``` | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ### Current typed commands | ||||
| 
 | ||||
| Say you have typed a long command and forgot to add `doas` in front: | ||||
| 
 | ||||
| ```console | ||||
| $ apt-get install build-essential | ||||
| ``` | ||||
| 
 | ||||
| By pressing the <kbd>esc</kbd> key twice, you will have the same command with `doas` prefixed without typing: | ||||
| 
 | ||||
| ```console | ||||
| $ doas apt-get install build-essential | ||||
| ``` | ||||
| 
 | ||||
| ### Previous executed commands | ||||
| 
 | ||||
| Say you want to delete a system file and denied: | ||||
| 
 | ||||
| ```console | ||||
| $ rm some-system-file.txt | ||||
| -su: some-system-file.txt: Permission denied | ||||
| $ | ||||
| ``` | ||||
| 
 | ||||
| By pressing the <kbd>esc</kbd> key twice, you will have the same command with `doas` prefixed without typing: | ||||
| 
 | ||||
| ```console | ||||
| $ rm some-system-file.txt | ||||
| -su: some-system-file.txt: Permission denied | ||||
| $ doas rm some-system-file.txt | ||||
| Password: | ||||
| $ | ||||
| ``` | ||||
| 
 | ||||
| Plugin inspired by sudo plugin by [Dongweiming](https://github.com/dongweiming) | ||||
|  | @ -1,32 +0,0 @@ | |||
| # ------------------------------------------------------------------------------ | ||||
| # Description | ||||
| # ----------- | ||||
| # | ||||
| # doas will be inserted before the command | ||||
| # | ||||
| # ------------------------------------------------------------------------------ | ||||
| # Authors | ||||
| # ------- | ||||
| # | ||||
| # * Anatoly <akopyl@radner.ru> | ||||
| # | ||||
| # ------------------------------------------------------------------------------ | ||||
| 
 | ||||
| doas-command-line() { | ||||
|     [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" | ||||
|     if [[ $BUFFER == doas\ * ]]; then | ||||
|         if [[ ${#LBUFFER} -le 4 ]]; then | ||||
|             RBUFFER="${BUFFER#doas }" | ||||
|             LBUFFER="" | ||||
|         else | ||||
|             LBUFFER="${LBUFFER#doas }" | ||||
|         fi | ||||
|     else | ||||
|         LBUFFER="doas $LBUFFER" | ||||
|     fi | ||||
| } | ||||
| zle -N doas-command-line | ||||
| # Defined shortcut keys: [Esc] [Esc] | ||||
| bindkey -M emacs '\e\e' doas-command-line | ||||
| bindkey -M vicmd '\e\e' doas-command-line | ||||
| bindkey -M viins '\e\e' doas-command-line | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue