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 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 rmtrash)" ] && alias rm='rmtrash' | ||||||
| [ -x "$(command -v rmdirtrash)" ] && alias rmdir='rmdirtrash' | [ -x "$(command -v rmdirtrash)" ] && alias rmdir='rmdirtrash' | ||||||
|  |  | ||||||
|  | @ -2,11 +2,13 @@ source "$HOME/.config/environment" | ||||||
| 
 | 
 | ||||||
| if [ ! -f "$ZSH/oh-my-zsh.sh" ] | if [ ! -f "$ZSH/oh-my-zsh.sh" ] | ||||||
| then | then | ||||||
|     echo "Installing oh-my-zsh" | 	echo "Installing oh-my-zsh" | ||||||
|     RUNZSH="no" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" > /dev/null | 	RUNZSH="no" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" > /dev/null | ||||||
|     rm "$HOME/.zshrc" | 	rm "$HOME/.zshrc" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  | autoinstall-packages | ||||||
|  | 
 | ||||||
| # Set name of the theme to load --- if set to "random", it will | # 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, | # 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 | # to know which specific one was loaded, run: echo $RANDOM_THEME | ||||||
|  | @ -67,27 +69,40 @@ HIST_STAMPS="yyyy-mm-dd" | ||||||
| # Would you like to use another custom folder than $ZSH/custom? | # Would you like to use another custom folder than $ZSH/custom? | ||||||
| ZSH_CUSTOM=$ZDOTDIR/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? | # Which plugins would you like to load? | ||||||
| # Standard plugins can be found in $ZSH/plugins/ | # Standard plugins can be found in $ZSH/plugins/ | ||||||
| # Custom plugins may be added to $ZSH_CUSTOM/plugins/ | # Custom plugins may be added to $ZSH_CUSTOM/plugins/ | ||||||
| # Example format: plugins=(rails git textmate ruby lighthouse) | # Example format: plugins=(rails git textmate ruby lighthouse) | ||||||
| # Add wisely, as too many plugins slow down shell startup. | # Add wisely, as too many plugins slow down shell startup. | ||||||
| plugins=( | plugins=( | ||||||
|     'colored-man-pages' | 	'colored-man-pages' | ||||||
|     'copypath' | 	'copypath' | ||||||
|     'copyfile' | 	'copyfile' | ||||||
|     'cp' | 	'cp' | ||||||
|     'docker' | 	'docker' | ||||||
|     'docker-compose' | 	'docker-compose' | ||||||
|     'extract' | 	'extract' | ||||||
|     'git' | 	'git' | ||||||
|     'git-auto-status' | 	'git-auto-status' | ||||||
|     'jump' | 	'jump' | ||||||
|     'laravel5' | 	'laravel5' | ||||||
|     'rust' | 	'rust' | ||||||
|     'safe-paste' | 	'safe-paste' | ||||||
|     'sudo' | 	'sudo' | ||||||
|     'vi-mode' | 	'vi-mode' | ||||||
|  | 	'zsh-syntax-highlighting' | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| source $ZSH/oh-my-zsh.sh | source $ZSH/oh-my-zsh.sh | ||||||
|  | @ -106,7 +121,4 @@ export SAVEHIST=1000000 | ||||||
| export HISTSIZE=1000000 | export HISTSIZE=1000000 | ||||||
| export HISTFILE="$HOME/.cache/zsh_history" | 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)" | [ -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