From 6927b0ca94157e2fb9dcd3b12766b4e913d0e44e Mon Sep 17 00:00:00 2001 From: Benoit Averty Date: Tue, 9 Aug 2016 11:22:02 +0200 Subject: [PATCH 1/2] Add directory permission prompt segment --- functions/icons.zsh | 3 +++ powerlevel9k.zsh-theme | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index df92d22a..44d99095 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -78,6 +78,7 @@ case $POWERLEVEL9K_MODE in PYTHON_ICON $'\U1F40D' # 🐍 SWIFT_ICON '' PUBLIC_IP_ICON '' + LOCK_ICON $'\UE138' #  ) ;; 'awesome-fontconfig') @@ -138,6 +139,7 @@ case $POWERLEVEL9K_MODE in PYTHON_ICON $'\U1F40D' # 🐍 SWIFT_ICON '' PUBLIC_IP_ICON '' + LOCK_ICON $'\UE138' #  ) ;; *) @@ -198,6 +200,7 @@ case $POWERLEVEL9K_MODE in PYTHON_ICON '' SWIFT_ICON 'Swift' PUBLIC_IP_ICON '' + LOCK_ICON $'\UE0A2' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f104b789..620a5f7d 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1114,6 +1114,13 @@ prompt_swift_version() { "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' } +# dir_permision: Display information about the user's permission to write in the current directory +prompt_dir_permission() { + if [[ ! -w "$PWD" ]]; then + "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "226" "" 'LOCK_ICON' + fi +} + ################################################################ # Prompt processing and drawing ################################################################ @@ -1240,4 +1247,3 @@ prompt_powerlevel9k_setup() { } prompt_powerlevel9k_setup "$@" - From 052eba9c74b2153dbd70eb4ba829f258a596baf2 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 31 Jan 2017 23:57:59 +0100 Subject: [PATCH 2/2] Rename `dir_permissions` segment to `dir_writable` Additionally: - Add changelog entry - Add documentation --- CHANGELOG.md | 4 ++++ README.md | 1 + powerlevel9k.zsh-theme | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index defc1dd0..5db1f6e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ Added an option to configure the path separator. If you want something else than an ordinary slash, you could set `POWERLEVEL9K_DIR_PATH_SEPARATOR` to whatever you want. +### New segment 'dir_writable' added + +This segment displays a lock icon if your user has no write permissions in the current folder. + ### New segment 'disk_usage' added This segment will show the usage level of your current partition. diff --git a/README.md b/README.md index f7a80a09..8f606f6b 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ The segments that are currently available are: * [`battery`](#battery) - Current battery status. * [`context`](#context) - Your username and host. * [`dir`](#dir) - Your current working directory. +* `dir_writable` - Displays a lock icon, if you do not have write permissions on the current folder. * [`disk_usage`](#disk_usage) - Disk usage of your current partition. * `history` - The command number for the current line. * [`ip`](#ip) - Shows the current IP address. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 620a5f7d..b89f390c 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1114,8 +1114,8 @@ prompt_swift_version() { "$1_prompt_segment" "$0" "$2" "magenta" "white" "${swift_version}" 'SWIFT_ICON' } -# dir_permision: Display information about the user's permission to write in the current directory -prompt_dir_permission() { +# dir_writable: Display information about the user's permission to write in the current directory +prompt_dir_writable() { if [[ ! -w "$PWD" ]]; then "$1_prompt_segment" "$0_FORBIDDEN" "$2" "red" "226" "" 'LOCK_ICON' fi